From patchwork Thu Nov 12 18:15:06 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gert Doering X-Patchwork-Id: 5680 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:6022:529c:b0:11a:a05e:cb97 with SMTP id x28csp2300080lax; Thu, 12 Nov 2026 10:15:26 -0800 (PST) X-Forwarded-Encrypted: i=2; AL+hErF2/s2mMSCpzV7F9JZTNDlndCQKSirR1Wm3hzVd1/DhkkNk10t69ehfyi67EbG03sHO1lRoio6+zqs=@openvpn.net X-Received: by 2002:a05:6820:3510:20b0:717:c:756e with SMTP id 006d021491bc7-719741e7627mr1337934eaf.29.1794507326152; Thu, 12 Nov 2026 10:15:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1794507326; cv=none; d=google.com; s=arc-20260327; b=hXYbcxWEhELJSKjc6KGuXxgl6W6ox2PHyaRVhr1KvGkLV1tqKij+n5366Ostnd/LV0 CTkR1OmLGoZq7t9ECZFSXKPmpPgmrnPzDY8Y83ezk7zvHFwf5es998PC4YdJ3vYmQSmW SvP6C9GX2xiCOYPy75rY+WEnvhjOH+MTD1C5U5T7Torsy5DYbOQCUBwbCaRSUjpKPB/w VnKhkiKAzsR9fjFJVv7ly33LMaw3ixk/h43db3jiwdo951Bzt534nT34NIhlS195pJC/ 2fOTmLsEMH0tvk34B6/Ul/FO4dVlleJyueoJ//KhT7t4AYPFfq9WDRQz33ZbAhGq84N4 gaHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; 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=CvKav9UixsakgpLplKlrE5kQLE6TbXlExIDXFvOvA9c=; fh=4NbAC/LsuMLI0S0hprUlLSLCiHwg6SCAifhH718Jh0Q=; b=SqlXZRbtD46MIxY2QXmndQ1EeAikZCZfU1aC4dcuOFakF025YavqpV4cVsQtpZKZ7o lViPwMtXtgRhaSoIMQj1X7UX1O3ZTW8oGjc/RgdsEj3S/aD2D4zzRrLNSs/zoOTpfYz0 Hp9Td7p7f6cJjJ4b1JV3HAuv5aFAgtcBNL7xKwpxrKCaaAtERBifw4tVvRQPP3Jdxnwp li48uFZO6o4R8F7bF2IKOINq+YKsjGsUiG9QLnaGuHXNf0GIH/pkC8fdboYwQr5LHeyK 4EcMe9zwQUMcu1C4q86A8e+WXpS/nT8dC70Z1aPf5gcSiONJU34s20jRZ9ombautPQEF qUQA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.sourceforge.net header.s=beta header.b=DfYMmMwc; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=dMYfJ+50; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=QlS1S0PG; 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 006d021491bc7-71ab41909aasi133372eaf.19.2026.11.12.10.15.25 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 12 Nov 2026 10:15:26 -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=DfYMmMwc; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=dMYfJ+50; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=QlS1S0PG; 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-Unsubscribe-Post: List-Owner; bh=CvKav9UixsakgpLplKlrE5kQLE6TbXlExIDXFvOvA9c=; b=DfYMmMwcVXqHdO yn3qh1f94dDCxUORz41z5BF4rjADxGWbwj1hn6eqqc5lEWl1C5eNTSD15iArHN9J1MtqBEnlIq0uX f1ea9/6vcOwLxJQOA3jyaKc4JHZ3oPfCGgPqnNMxMnrV9ugJalA+p2GqCiTY6+lkmO3sBxdjvWKS/ hC8=; 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.100.1) (envelope-from ) id 1xRZKV-000000007cB-2EQA; Thu, 12 Nov 2026 18:15:23 +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.100.1) (envelope-from ) id 1xRZKT-000000007c5-3sHf for openvpn-devel@lists.sourceforge.net; Thu, 12 Nov 2026 18:15:21 +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-Unsubscribe-Post:List-Subscribe:List-Post:List-Owner:List-Archive; bh=bPVypZVXefw54nlewmhWvdbSRiNbbNqAe4N4x9gwHiI=; b=dMYfJ+50RG2xCJR18sDeCJt2uQ KNAcm0zDM8GrShLfoeOOF72Xx/K+2k6woIVdLM1kQUjfyTHHMvaO4hc62HLkWMb9fjs860o+MltSp WPj6UjUKzEpjEj1BfT7cAlGp8HHU+jlZ4mcIABiPmuntNXKFxWqdH2KIqpmjgeCeRDFM=; 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-Unsubscribe-Post: List-Subscribe:List-Post:List-Owner:List-Archive; bh=bPVypZVXefw54nlewmhWvdbSRiNbbNqAe4N4x9gwHiI=; b=QlS1S0PGl3vui6UdPNshbyACtk tBvK5Y6qEA0jra1yPOvg2h9MIdKkJBORo/l6nXW6TWV/gZWQnTuqG+XtxNYicWepd9RR3P1yVTHKX sAKS7m1RGWmnvNgW5Xg7PMqu2eNokbzhUDmn6FUTf9cp4jXais+tcI1Phf0xkgYLkSPc=; 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.100.1) id 1xRZKS-000000000r2-13HC for openvpn-devel@lists.sourceforge.net; Thu, 12 Nov 2026 18:15:21 +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 6ACIFDlA027230 for ; Thu, 12 Nov 2026 19:15:13 +0100 Received: (from gert@localhost) by blue.greenie.muc.de (8.18.2/8.18.1/Submit) id 6ACIFD8H027224 for openvpn-devel@lists.sourceforge.net; Thu, 12 Nov 2026 19:15:13 +0100 From: Gert Doering To: openvpn-devel@lists.sourceforge.net Date: Thu, 12 Nov 2026 19:15:06 +0100 Message-ID: <20261112181513.27212-1-gert@greenie.muc.de> X-Mailer: git-send-email 2.55.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-1.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: Razvan Cojocaru GetNrptExcludeData() stored the IPv6 name servers after the IPv4 list, but the IPv4 size includes the terminating NUL. With both present, the string ended at the IPv4 list and the IPv6 servers never m [...] 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: 1xRZKS-000000000r2-13HC Subject: [Openvpn-devel] [PATCH v4] openvpnserv: keep IPv6 name servers in NRPT exclude rules 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: 1881677313884320587 X-GMAIL-MSGID: 1881677313884320587 From: Razvan Cojocaru GetNrptExcludeData() stored the IPv6 name servers after the IPv4 list, but the IPv4 size includes the terminating NUL. With both present, the string ended at the IPv4 list and the IPv6 servers never made it into GenericDNSServers. Join the lists by replacing that NUL with a delimiter. Both readers now start from an empty string: RegGetValueA() leaves the buffer untouched when the value is missing, and a slot is reused after an interface is skipped, so an interface without name servers could inherit those of the skipped one. They also return the length of the list without trailing delimiters, instead of the registry value size, which can include NUL padding. Broken since 0f3b7d17 ("win: implement --dns option support with NRPT"). Change-Id: Ic602b125d857f1beed4af8661f522d339bc9e972 Signed-off-by: Razvan Cojocaru Acked-by: Heiko Hund Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/2162 --- 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/+/2162 This mail reflects revision 4 of this Change. Acked-by according to Gerrit (reflected above): Heiko Hund diff --git a/src/openvpnserv/interactive.c b/src/openvpnserv/interactive.c index 81205d6..1b76003 100644 --- a/src/openvpnserv/interactive.c +++ b/src/openvpnserv/interactive.c @@ -2128,6 +2128,24 @@ } /** + * Remove trailing delimiters from a name server list + * + * @param addrs NUL-terminated list of addresses + * + * @return the size of the list in bytes, including the terminating NUL + */ +static DWORD +TrimNameServers(PSTR addrs) +{ + size_t len = strlen(addrs); + while (len && (addrs[len - 1] == ',' || addrs[len - 1] == ' ')) + { + addrs[--len] = '\0'; + } + return (DWORD)len + 1; +} + +/** * Get DNS server IPv4 addresses of an interface * * @param itf_key registry key of the IPv4 interface data @@ -2140,6 +2158,7 @@ static LSTATUS GetItfDnsServersV4(HKEY itf_key, PSTR addrs, PDWORD size) { + addrs[0] = '\0'; addrs[*size - 1] = '\0'; LSTATUS err; @@ -2165,7 +2184,7 @@ if (strchr(addrs, '.')) { - *size = s; + *size = TrimNameServers(addrs); return NO_ERROR; } @@ -2178,13 +2197,15 @@ * * @param itf_key registry key of the IPv6 interface data * @param addrs pointer to the buffer addresses are returned in - * @param size pointer to the size of the buffer + * @param size pointer to the size of the buffer, contains the + * size of the addresses on return * * @return LSTATUS NO_ERROR on success, a Windows error code otherwise */ static LSTATUS GetItfDnsServersV6(HKEY itf_key, PSTR addrs, PDWORD size) { + addrs[0] = '\0'; addrs[*size - 1] = '\0'; LSTATUS err; @@ -2231,12 +2252,11 @@ pos += addr_len; s -= (DWORD)addr_len; } - s = (DWORD)strlen(addrs) + 1; } if (strchr(addrs, ':')) { - *size = s; + *size = TrimNameServers(addrs); return NO_ERROR; } @@ -2563,6 +2583,11 @@ __func__, itf_guid, err); goto next_itf; } + if (v4_addrs_size && v6_addrs_size) + { + /* Join the lists: replace the v4 terminating NUL with a delimiter */ + data[i].addresses[v4_addrs_size - 1] = ','; + } } if (v4_addrs_size || v6_addrs_size)