From patchwork Wed Jan 21 12:18:30 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Lichtenheld X-Patchwork-Id: 4726 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7000:91d9:b0:80a:3855:ce6a with SMTP id k25csp732192maf; Wed, 21 Jan 2026 04:18:46 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWNmeDxk46QbxSF0R4TlQxw6r1PIy7cm0a8Cwcdt9UCn4OYqs6j3vyqKuD8NwJD3p35xsbDRwLnS9w=@openvpn.net X-Received: by 2002:a05:6820:80f:b0:65f:75e4:3478 with SMTP id 006d021491bc7-662b00f03f1mr1864880eaf.76.1768997926375; Wed, 21 Jan 2026 04:18:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1768997926; cv=none; d=google.com; s=arc-20240605; b=ABxhYA6pGF6uLqJdt6onWWieKRroUu3LAwCGViJNxjPS11mxFbUUfRAuwd+AYECcQK UqEo86YJQKi9knNOPiEgBQlFhHXD6nIUqxB2Oj4YOfM0iZEp58CuEZJvy/0WTe1hPKUb NEd9xRvuax2iei51hUXEBX/+aHaSmFhWUxPIXuCTe9U7r89nul3Pkmd2K4nn7nU2UzO2 DyyKON78CbJi25pgX8kYdLMMOkwONJAQn6yqTbFfoe/6HYMbOoeDrnxKPM52aT1S5cxy X03wkt0WJoEEajmAbm9a4mSKqZVoFPCKCxNA+L5fJPPFlw5O8H7/n/0bopfCQn16aZ5+ eRHQ== 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:dkim-signature; bh=Hbid9J/WmOHc3+OrOFtNlJSPzj1crvIAQmCqs9Knae8=; fh=4NbAC/LsuMLI0S0hprUlLSLCiHwg6SCAifhH718Jh0Q=; b=c6fzcmbcz/qePzJxR7UHWoG7MUA/NC89jpGHegz/pooKTyIl0fng/+GK2P0MyjO33C uj2Yr+dsLeAsmSU2aiWWm9rVyw3GC+fZRlrFSEnl7nXmyORwMVMy075pAgv/2ZxBX5bF L7wVwFTkGkPmeVY0+OhRqRdpCl4r554uPJzMlatGKPT2iatIhxeb9+WUwpYOasvNdYKD Is5WsyBqeo0DC1DHdAYnB8XCq4S4Ql7oSw3Pf0GkK8fogZlqiI033W7o7XPVBTt0ebfC vvMuBI3kYBWoku5OlaKBs3TiBBxQh3u4jck42eBg346dkWe+8/CGR/iKQirZ572H/qnC lHtg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.sourceforge.net header.s=beta header.b=bA2SVo9J; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=cXCX97p2; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=lDz3pB8R; dkim=neutral (body hash did not verify) header.i=@lichtenheld.com header.s=MBO0001 header.b=gOjHu8da; 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 Received: from lists.sourceforge.net (lists.sourceforge.net. [216.105.38.7]) by mx.google.com with ESMTPS id 586e51a60fabf-4044bb1b17dsi11362332fac.57.2026.01.21.04.18.46 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 21 Jan 2026 04:18:46 -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=bA2SVo9J; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=cXCX97p2; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=lDz3pB8R; dkim=neutral (body hash did not verify) header.i=@lichtenheld.com header.s=MBO0001 header.b=gOjHu8da; 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 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=Hbid9J/WmOHc3+OrOFtNlJSPzj1crvIAQmCqs9Knae8=; b=bA2SVo9J7ULPiGuApBEYFW+yU+ j0Actagt1DH+tk204zSP8ijK+E1zqqs9PLlaFyl3AwOVCAS6viJ8FQYy9XRV/h54KmiX4Hha6pUGx +FIGp7vZ3wnF+7FhssB4mtZqEpUbs1ncs+2bhQ4YV98/Yk4DKYr6WlLsqsYVymVCo1b0=; Received: from [127.0.0.1] (helo=sfs-ml-1.v29.lw.sourceforge.com) by sfs-ml-1.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1viXAZ-0004gZ-Tv; Wed, 21 Jan 2026 12:18:43 +0000 Received: from [172.30.29.66] (helo=mx.sourceforge.net) by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1viXAX-0004gQ-Pm for openvpn-devel@lists.sourceforge.net; Wed, 21 Jan 2026 12:18:42 +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:Cc:To:From:Sender:Reply-To: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=JAoF3oSf9inQVl6XZkqhYVxrd4j0qiA5zp0x+UpkpM8=; b=cXCX97p2WF8ksUjCydwBrVqliv onzmGA4pVs2UnN3WIm2vKr8t1iQVm7umySOMk7bQqFFkcJMeIQC00PYspZBJtTVvbZJEF/1G0vPN3 28dpojg0/FCIhuwGaXawY/ml0UrBoqhTm0NZhujWYxfC1CLeB0q6RSZzI/rVNdsBNHkc=; 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:Cc:To:From:Sender:Reply-To: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=JAoF3oSf9inQVl6XZkqhYVxrd4j0qiA5zp0x+UpkpM8=; b=lDz3pB8RXLYoZCL4ziI7mAH7hF Yc5LJbArkGA86rWHAxJkh7apg6krznI0BBWYF2xtrXF9YmMUnR/2fZbceP0WJJiQGaeMSBZ9E1q3/ s1NziCxwxf5004mM8Sc+l5D+azfqNOi37/IYO8zHOxkVPcxAtCaMn5CE0G1hoRHMwLTA=; Received: from mout-p-202.mailbox.org ([80.241.56.172]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1viXAW-0001yT-Vl for openvpn-devel@lists.sourceforge.net; Wed, 21 Jan 2026 12:18:41 +0000 Received: from smtp2.mailbox.org (smtp2.mailbox.org [IPv6:2001:67c:2050:b231:465::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-202.mailbox.org (Postfix) with ESMTPS id 4dx3Bc2mT0z9tnv; Wed, 21 Jan 2026 13:18:32 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lichtenheld.com; s=MBO0001; t=1768997912; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=JAoF3oSf9inQVl6XZkqhYVxrd4j0qiA5zp0x+UpkpM8=; b=gOjHu8dab0iAMiu2h/PrwpkTjyTRG3LJ4WuGPyPHPRehv9SnSm0VTcx3TE1E49d8y1bCpc CedXQY+LRVRNTGD3eTgjWRp9BUT7ukKBS0Dmi/EneHEDvFj9Inn4xw/jdYTHcpoVYLSqJm MnTMqQklJNKhRO3m4IW10AVue8p/KTXwEBVAV7/pRMWAQmBbq8onJxsR907kzPY7qK7o7/ cF3f+O1FWER09EEvP6NUTA8JA5ButGxTAGATV5nDmhnRD5UN/1y1TL/tT8HN0MlwoXNHqR 2nroxxC6I+bm4IoMIz5piokckOOJt9xpd4pnsc/Se6vvBgJA+mjWBAwDMRkI/A== Authentication-Results: outgoing_mbo_mout; dkim=none; spf=pass (outgoing_mbo_mout: domain of frank@lichtenheld.com designates 2001:67c:2050:b231:465::2 as permitted sender) smtp.mailfrom=frank@lichtenheld.com From: Frank Lichtenheld To: openvpn-devel@lists.sourceforge.net Date: Wed, 21 Jan 2026 13:18:30 +0100 Message-ID: <20260121121830.27244-1-frank@lichtenheld.com> In-Reply-To: References: MIME-Version: 1.0 X-Rspamd-Queue-Id: 4dx3Bc2mT0z9tnv X-Spam-Score: -0.2 (/) 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: Arne Schwabe On the more recent mingw compilers (homebrew mingw 13.0.0, GCC 15.2.0) the compiler complains about a potential truncation in these two places. src/openvpn/tun.c:3806:57: error: '%s' directive output may be truncated writing up to 255 bytes into a region of size 178 [-Werror=format-truncation=] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain X-Headers-End: 1viXAW-0001yT-Vl Subject: [Openvpn-devel] [PATCH v4] Silence compiler truncation warning by checking snprintf return value 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?1854928769455012072?= X-GMAIL-MSGID: =?utf-8?q?1854928769455012072?= From: Arne Schwabe On the more recent mingw compilers (homebrew mingw 13.0.0, GCC 15.2.0) the compiler complains about a potential truncation in these two places. src/openvpn/tun.c:3806:57: error: '%s' directive output may be truncated writing up to 255 bytes into a region of size 178 [-Werror=format-truncation=] This not very helpful but checking the snprintf return value will make the compiler not warn about this. Change-Id: I54b11a5540fb236580a3b80c6d1e8678b24bd852 Signed-off-by: Arne Schwabe Acked-by: Frank Lichtenheld Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1272 --- 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/+/1272 This mail reflects revision 4 of this Change. Acked-by according to Gerrit (reflected above): Frank Lichtenheld diff --git a/src/openvpn/tun.c b/src/openvpn/tun.c index 0399b4a..e38df3e 100644 --- a/src/openvpn/tun.c +++ b/src/openvpn/tun.c @@ -3558,7 +3558,13 @@ msg(M_FATAL, "Error enumerating registry subkeys of key: %s", ADAPTER_KEY); } - snprintf(unit_string, sizeof(unit_string), "%s\\%s", ADAPTER_KEY, enum_name); + int ret = snprintf(unit_string, sizeof(unit_string), "%s\\%s", ADAPTER_KEY, enum_name); + + if (ret < 0 || ret >= sizeof(unit_string)) + { + msg(M_WARN, "Error constructing unit string for %s", enum_name); + continue; + } status = RegOpenKeyEx(HKEY_LOCAL_MACHINE, unit_string, 0, KEY_READ, &unit_key); @@ -3667,8 +3673,15 @@ msg(M_FATAL, "Error enumerating registry subkeys of key: %s", NETWORK_CONNECTIONS_KEY); } - snprintf(connection_string, sizeof(connection_string), "%s\\%s\\Connection", - NETWORK_CONNECTIONS_KEY, enum_name); + int ret = snprintf(connection_string, sizeof(connection_string), "%s\\%s\\Connection", + NETWORK_CONNECTIONS_KEY, enum_name); + + if (ret < 0 || ret >= sizeof(connection_string)) + { + msg(M_WARN, "Error constructing connection string for %s", enum_name); + continue; + } + status = RegOpenKeyEx(HKEY_LOCAL_MACHINE, connection_string, 0, KEY_READ, &connection_key);