From patchwork Fri Mar 6 16:31:56 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gert Doering X-Patchwork-Id: 4806 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7001:a68f:b0:83c:d90d:321 with SMTP id wf15csp1674860mab; Fri, 6 Mar 2026 08:32:12 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCV/zvRZlgK3wcw6cKjOQ6+UZDWjZ30WwMqzFCHKmqhXnYCYFvFIFg8Zkj8jfQluI6XhFUOFVuJmVMo=@openvpn.net X-Received: by 2002:a05:6808:3509:b0:45a:58af:fed6 with SMTP id 5614622812f47-466cd15fba7mr3055970b6e.17.1772814732588; Fri, 06 Mar 2026 08:32:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1772814732; cv=none; d=google.com; s=arc-20240605; b=eisnfXgd3eny0ybiDL9Fwb6gTtKdRmq8F30xn5CssoihlrnC3ZE0G85hy5tpWaU5Bq qMbIaNgD67pfP0/02uRDlA/mNYGghHFivhpibuSuzBdyQu3OSEjAd18FjUDpfr62xXkN sLoF6mhSveWLGSxm6P1Xg3wqKEsRJsYRhqmMXqIj1NJhgGxIZkZqtqFu2pqb8QnfK52l jYgGIcy5IFGPOS7KOkbzaSe5pb+MCJIlzb2c7kDflRrcJY9YkmNIXSQgoEtXBPiUyc2y dCPOgbQlL8/M+1lJk+dMYCcrLdYCv+h5NNZG2EqL3HVWv8eQcMKntkp0fgnDXiHD3XBv IHpw== 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=msFE+QCdxhAqW4QFgBj4Y9AWSIKMIYisQHDmNacKDfs=; fh=4NbAC/LsuMLI0S0hprUlLSLCiHwg6SCAifhH718Jh0Q=; b=Gb2W0Wq2hSX5cAhcauPD6abk804NjOCO0QS6d39VnfBwqOqI3/Qx9ft7tk4wU4EAhS kvPeunbP+bEELcRjbgKDTzYVe6gyVc2bE5B6H18UakIROgvcWM+7jJBk+AiBXU0Lhvku r7x/fLku5hjz8r4Qe4j8/5fgEAsTFWmPjPt2bifiTKZp3ZMmqwk5UxcgiC9so0iCo6mh InbfX2RNCO639ou+DzjJyKp7u9NqVEhJAKU7gBZJFaMYc3ZM0ebJXIEOTdm2rcNDynbz NqdI4IM8YbfJY9bpfvM7G8Hx3pJoC8lzXVsvvTZ29ZY5OPqCAVTwyF3zfgaoqQU8gmzm AnpQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.sourceforge.net header.s=beta header.b=Sx7hzNsb; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=gBnueRcc; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=evsS9IU+; 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-7d728da8e72si1109741a34.138.2026.03.06.08.32.12 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 06 Mar 2026 08:32:12 -0800 (PST) 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=Sx7hzNsb; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=gBnueRcc; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=evsS9IU+; 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=msFE+QCdxhAqW4QFgBj4Y9AWSIKMIYisQHDmNacKDfs=; b=Sx7hzNsbZjBXz6b1lS+2kjdYYA RG/C87wK+bQNu9RbJG+U9MkBPN9jSDCceszUSAh6bEhiovSWsLL5JJwJ8BO4czfiGQukBeJJemxlZ dh3mUq0SODhXEWcLbpS2mRQcLfUULKlC1Jsa1ox1tRtqNePLLrmDUQD++VPfuBQEo1gc=; Received: from [127.0.0.1] (helo=sfs-ml-4.v29.lw.sourceforge.com) by sfs-ml-4.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1vyY5y-0004ye-Md; Fri, 06 Mar 2026 16:32:10 +0000 Received: from [172.30.29.66] (helo=mx.sourceforge.net) by sfs-ml-4.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1vyY5y-0004yX-1V for openvpn-devel@lists.sourceforge.net; Fri, 06 Mar 2026 16:32:10 +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=DrFzYQBnZwP2KLB5PtWCg/FyIClhvy7/dXimWVICNJU=; b=gBnueRccfhCAKZIxGZX+NBNwhJ yIm3Z0G7+sfbp27HeSQsyvaxj++apOIB+z513bLBMjcVEbPxobdiywufDaMYx6fs/Lkkvy7styWyP lbrQ1iZJ/bSz8mqrEG8zXb6+GSXHZlownbkqHZxX9rIWC7uimPfHSrZBXWvIzdc/aJoE=; 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=DrFzYQBnZwP2KLB5PtWCg/FyIClhvy7/dXimWVICNJU=; b=evsS9IU+vQwyrTpglbk54VSNZe wJYPNT1dahi7WQzWkF7NPWRUjQk0jEHTdmf44zp7VDe/tZiKy5ZD/ctCcLpEMLU7kS8nMm1UiZNaE i3Ir8qtxQVkSkeLOh4rs7VM69CWIlo8RHMNhJle3skSVg5mJaTksYHoFE/wtoHyJIlAk=; 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 1vyY5x-00062g-59 for openvpn-devel@lists.sourceforge.net; Fri, 06 Mar 2026 16:32:09 +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 626GW2aC002607 for ; Fri, 6 Mar 2026 17:32:02 +0100 Received: (from gert@localhost) by blue.greenie.muc.de (8.18.1/8.18.1/Submit) id 626GW2O0002606 for openvpn-devel@lists.sourceforge.net; Fri, 6 Mar 2026 17:32:02 +0100 From: Gert Doering To: openvpn-devel@lists.sourceforge.net Date: Fri, 6 Mar 2026 17:31:56 +0100 Message-ID: <20260306163202.2586-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 The assignment implicitly converts the values, but we can just do the comparison before the assignment. Change-Id: Idf5ce8f82e7727505cce67560e0b7423b8e41a40 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: 1vyY5x-00062g-59 Subject: [Openvpn-devel] [PATCH v3] socket: Avoid sign-compare issue by comparing before assignment 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?1858930980724484710?= X-GMAIL-MSGID: =?utf-8?q?1858930980724484710?= From: Frank Lichtenheld The assignment implicitly converts the values, but we can just do the comparison before the assignment. Change-Id: Idf5ce8f82e7727505cce67560e0b7423b8e41a40 Signed-off-by: Frank Lichtenheld Acked-by: Gert Doering Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1523 --- 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/+/1523 This mail reflects revision 3 of this Change. Acked-by according to Gerrit (reflected above): Gert Doering diff --git a/src/openvpn/socket.c b/src/openvpn/socket.c index 8d2d110..5df0792 100644 --- a/src/openvpn/socket.c +++ b/src/openvpn/socket.c @@ -2550,11 +2550,6 @@ return WSAGetLastError(); } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wsign-compare" -#endif - int socket_recv_queue(struct link_socket *sock, int maxsize) { @@ -2579,11 +2574,10 @@ /* Win32 docs say it's okay to allocate the wsabuf on the stack */ wsabuf[0].buf = BSTR(&sock->reads.buf); + /* make sure maxsize is sane */ + ASSERT(maxsize <= BLEN(&sock->reads.buf)); wsabuf[0].len = maxsize ? maxsize : BLEN(&sock->reads.buf); - /* check for buffer overflow */ - ASSERT(wsabuf[0].len <= BLEN(&sock->reads.buf)); - /* the overlapped read will signal this event on I/O completion */ ASSERT(ResetEvent(sock->reads.overlapped.hEvent)); sock->reads.flags = 0; @@ -2656,10 +2650,6 @@ return sock->reads.iostate; } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic pop -#endif - int socket_send_queue(struct link_socket *sock, struct buffer *buf, const struct link_socket_actual *to) {