From patchwork Mon Mar 30 11:36:39 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gert Doering X-Patchwork-Id: 4855 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7000:6c4a:b0:83c:d90d:321 with SMTP id c10csp1384069may; Mon, 30 Mar 2026 04:37:07 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVbY9+euAaHJqcCLb/tdSOu57NNGKm848VqCurg0sQTqrDp/+pHFcWi5n8ooVNK1XZAc5Iu5DTUnFg=@openvpn.net X-Received: by 2002:a05:6830:828e:b0:7d7:fcbb:f81e with SMTP id 46e09a7af769-7d9faed03a4mr6914910a34.21.1774870626853; Mon, 30 Mar 2026 04:37:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1774870626; cv=none; d=google.com; s=arc-20240605; b=Oburi5vXSCKjcXoKGegySOgS1hSOepQJ3SjY479/S/FowMVwPik7PT+JB5h1JoTg5u H2zM7XkhW+RVGVp5p3eWgjnWuvlqE+4pTalaF54MXqFHA0pF3V1nCYSlc5LjO7C3ufCt 70U+xocjjAGSy4i7Vy9t3UIMIpSVqlImgF7vConelMKjllUuvH3Eiig0PP1Om4YNpu2C 0XhDNPaL83VY6uuircNI5W8loM0Lyzf60YsOgumTvTgjorCYADJpsk3n1XqK1sGq78oi UyrvqsprUD6Bep0Adi7J31P68nvq35syxCI0zW2eJG5ocUH8qIWnwQX8r1sEsZt6vlWu Z3lw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=errors-to:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:date:to:from :dkim-signature:dkim-signature:dkim-signature; bh=6/pebXPrPHq4cq9LmNNSvhfdLypwFDdbYx7Ekxc4iS8=; fh=4NbAC/LsuMLI0S0hprUlLSLCiHwg6SCAifhH718Jh0Q=; b=XgvYJ+2H7Zqd1GNebsnNlXFPBEnoluHty2hWQS6ysuCWnbj2OwFo7MYvHb8nIVpRcN Lxr26bJMrijDExQ40RbRh0kiGmEMfXN1pQt4k+bIKIeaapL3NgbapU+1OuvZeXhCNf3y b6CFuZ13UJW5BgDlgrYft09YpjB2EZF3SxfFOr1jKk7FqOxoXvzN4/oHtnDetj3D8zBa HAFHnG3VuVk+S2Rtqb7F8UnmxicqUMo43KzNUW67dbFET5Dz/lCXJcZ+TX4M3OOM1R4z Qd9TCzWKBppnoNXzl2sn44dlWAfvdT59Pg3NXiLIN/VoLnMNbhEx/pHYUTrPL4GDSbXW FCvQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.sourceforge.net header.s=beta header.b=I1zuwUlP; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b="i/54MNNn"; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=MyPwcxeW; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=muc.de Received: from lists.sourceforge.net (lists.sourceforge.net. [216.105.38.7]) by mx.google.com with ESMTPS id 46e09a7af769-7da0a8ce966si5399347a34.103.2026.03.30.04.37.06 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 30 Mar 2026 04:37:06 -0700 (PDT) Received-SPF: pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) client-ip=216.105.38.7; Authentication-Results: mx.google.com; dkim=pass header.i=@lists.sourceforge.net header.s=beta header.b=I1zuwUlP; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b="i/54MNNn"; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=MyPwcxeW; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=muc.de DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.sourceforge.net; s=beta; h=Content-Transfer-Encoding:Content-Type: List-Subscribe:List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: Subject:MIME-Version:References:In-Reply-To:Message-ID:Date:To:From:Sender: Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=6/pebXPrPHq4cq9LmNNSvhfdLypwFDdbYx7Ekxc4iS8=; b=I1zuwUlPk7DLV1o4v9vbE/QzjV X940EsbupEsp7kux0rP3EdtWBZgA1UK/uNP701DLjr8UX+NWSYn54Rxk9HyX/BBduWGJX0OnU3NW5 vya+1i/3e8xxTX4ryTBjSK02LtX2cTtoBHMk0zycdj1L1rrExfxEuNi2Mz3dR2IfYyMI=; Received: from [127.0.0.1] (helo=sfs-ml-3.v29.lw.sourceforge.com) by sfs-ml-3.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1w7AvY-0002KI-7K; Mon, 30 Mar 2026 11:37:04 +0000 Received: from [172.30.29.66] (helo=mx.sourceforge.net) by sfs-ml-3.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1w7AvW-0002KA-Jp for openvpn-devel@lists.sourceforge.net; Mon, 30 Mar 2026 11:37:02 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:To:From:Sender:Reply-To:Cc:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=bu/G9rW9MKvHhSXeuoPHkmT3O1hASxAp20VYbWZqcZg=; b=i/54MNNnR68QgjHzl4ACcYNtdi Qr6jbrwDqRvdI+ErJxyOipAKOrkysvI6HA0oIi6ujfNnPvGxCYlQA60ZgpzHP/QrUekvwome4o4ZP MchQR8NPlq952uF3dCTMNRocOW02ZTj7CZ5vbuu5p4a3CfEn60lknJ16oXMY4rGgoy8s=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID: Date:Subject:To:From:Sender:Reply-To:Cc:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=bu/G9rW9MKvHhSXeuoPHkmT3O1hASxAp20VYbWZqcZg=; b=MyPwcxeW9uIq3Dl18zcghwBYyG C8kEsvdztvv16JliaImtGIqngj355sG3KqAvHjhO/OKnY3vjXE/pf8s/8R5hEcpCMROIrPNNZEo8N DnqKNzEEIt447vf5xebZ2kBT/IJS2E5/FbzySTa4fkk/IQYgl0GdxaD+CswlYq+gZyjo=; Received: from [193.149.48.129] (helo=blue.greenie.muc.de) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1w7AvV-0000Bm-L0 for openvpn-devel@lists.sourceforge.net; Mon, 30 Mar 2026 11:37:02 +0000 Received: from blue.greenie.muc.de (localhost [127.0.0.1]) by blue.greenie.muc.de (8.18.1/8.18.1) with ESMTP id 62UBamZY019912 for ; Mon, 30 Mar 2026 13:36:48 +0200 Received: (from gert@localhost) by blue.greenie.muc.de (8.18.1/8.18.1/Submit) id 62UBamn5019911 for openvpn-devel@lists.sourceforge.net; Mon, 30 Mar 2026 13:36:48 +0200 From: Gert Doering To: openvpn-devel@lists.sourceforge.net Date: Mon, 30 Mar 2026 13:36:39 +0200 Message-ID: <20260330113648.19896-1-gert@greenie.muc.de> X-Mailer: git-send-email 2.52.0 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Score: 1.3 (+) X-Spam-Report: Spam detection software, running on the system "sfi-spamd-2.hosts.colo.sdot.me", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: From: Frank Lichtenheld - Switch buffer_list size and max_size to size_t - Guard some unavoidable size_t -> int conversions Change-Id: Iecc3e3d5d13cb85c1f287ad4816e1e6a7b2bcdef Signed-off-by: Frank Lichtenheld Acked-by: Gert Doering Gerrit URL: https://gerrit.openvpn.net/c/open [...] Content analysis details: (1.3 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 1.3 RDNS_NONE Delivered to internal network by a host with no rDNS X-Headers-End: 1w7AvV-0000Bm-L0 Subject: [Openvpn-devel] [PATCH v5] buffer: Avoid sign-compare warnings X-BeenThere: openvpn-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox X-GMAIL-THRID: =?utf-8?q?1861086742760514109?= X-GMAIL-MSGID: =?utf-8?q?1861086742760514109?= From: Frank Lichtenheld - Switch buffer_list size and max_size to size_t - Guard some unavoidable size_t -> int conversions Change-Id: Iecc3e3d5d13cb85c1f287ad4816e1e6a7b2bcdef Signed-off-by: Frank Lichtenheld Acked-by: Gert Doering Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1561 --- This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master. Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1561 This mail reflects revision 5 of this Change. Acked-by according to Gerrit (reflected above): Gert Doering diff --git a/src/openvpn/buffer.c b/src/openvpn/buffer.c index 75110ed..71f3769 100644 --- a/src/openvpn/buffer.c +++ b/src/openvpn/buffer.c @@ -53,7 +53,7 @@ void buf_size_error(const size_t size) { - msg(M_FATAL, "fatal buffer size error, size=%lu", (unsigned long)size); + msg(M_FATAL, "fatal buffer size error, size=%zu", size); } struct buffer @@ -280,11 +280,6 @@ return ret; } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wsign-compare" -#endif - /* * write a string to the end of a buffer that was * truncated by buf_printf @@ -295,7 +290,7 @@ if (buf_forward_capacity(buf) <= 1) { size_t len = strlen(str) + 1; - if (len < buf_forward_capacity_total(buf)) + if (buf_size_valid(len) && (int)len < buf_forward_capacity_total(buf)) { memcpy(buf->data + buf->capacity - len, str, len); } @@ -782,7 +777,7 @@ buf_string_match_head_str(const struct buffer *src, const char *match) { const size_t size = strlen(match); - if (size > src->len) + if (!buf_size_valid(size) || (int)size > src->len) { return false; } @@ -1196,7 +1191,7 @@ bool buffer_list_defined(const struct buffer_list *ol) { - return ol && ol->head != NULL; + return ol && ol->head != NULL && ol->size > 0; } void @@ -1223,7 +1218,7 @@ struct buffer_entry *e = buffer_list_push_data(ol, str, len + 1); if (e) { - e->buf.len = (int)len; /* Don't count trailing '\0' as part of length */ + e->buf.len--; /* Don't count trailing '\0' as part of length */ } } } @@ -1249,6 +1244,7 @@ } e->buf = alloc_buf(size); memcpy(e->buf.data, data, size); + /* Note: size implicitly checked by alloc_buf */ e->buf.len = (int)size; ol->tail = e; } @@ -1274,7 +1270,7 @@ const size_t sep_len = strlen(sep); struct buffer_entry *more = bl->head; size_t size = 0; - int count = 0; + size_t count = 0; for (; more; ++count) { size_t extra_len = BLENZ(&more->buf) + sep_len; @@ -1313,10 +1309,6 @@ } } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic pop -#endif - void buffer_list_aggregate(struct buffer_list *bl, const size_t max) { @@ -1326,7 +1318,7 @@ void buffer_list_pop(struct buffer_list *ol) { - if (ol && ol->head) + if (buffer_list_defined(ol)) { struct buffer_entry *e = ol->head->next; free_buf(&ol->head->buf); diff --git a/src/openvpn/buffer.h b/src/openvpn/buffer.h index 040f752..fcc923b 100644 --- a/src/openvpn/buffer.h +++ b/src/openvpn/buffer.h @@ -1149,8 +1149,8 @@ { struct buffer_entry *head; /* next item to pop/peek */ struct buffer_entry *tail; /* last item pushed */ - int size; /* current number of entries */ - int max_size; /* maximum size list should grow to */ + size_t size; /* current number of entries */ + size_t max_size; /* maximum size list should grow to */ }; /**