From patchwork Wed Nov 26 10:34:21 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gert Doering X-Patchwork-Id: 4631 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7000:6c3:b0:7b1:439f:bdf with SMTP id j3csp3236091maw; Wed, 26 Nov 2025 02:34:40 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWxqSoEgus0M+6k/ZrWbIWFM1sl2s6vSqGjOUM2b+ajl/R6zUf5/83KschwuG8Ia2c4iADrV9pjrNA=@openvpn.net X-Google-Smtp-Source: AGHT+IEPRBJ1wXQ85n+8zQ/hmM9+f4vJRO+MIp6uYOUNs8Y1Sy+dE8YGOqQ/hH24IQiaM2lGecij X-Received: by 2002:a05:6808:c2d1:b0:450:3cbb:f1e2 with SMTP id 5614622812f47-45115ade6demr5866606b6e.46.1764153280313; Wed, 26 Nov 2025 02:34:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1764153280; cv=none; d=google.com; s=arc-20240605; b=BTjYwj/OsRX7/6X2Urv8N+c9uZ/nfoa5GmyDMqbExh8bQJISo/NFwdtapU21OENVRY sYRnFkYeqkUjvp5qvmroozZRqcbYDFXyYTBGPTV/vKiy33jzb+JNBhZm7QxRQyoLxAL6 AC0rjxPKWiplDp/ppefZYMe6AWhUw/78pXC2bCOqdMgbjNQCKAbrrxwmNSBYKzo4wdUX to5ZNV7E76eT/Oxqe4n/nSfCRPREx7phVfBQ643qe2rIqcQJxTwkKsfEu8joRxB3d2Od /xDfaJfZThbHW3SGmlNinj/+Dbm7BjR2sHTTcSNgxtEuv428oA7U3ndjp1EyUHY6d3aP AvtA== 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=C6Ws8sEymFofQUIxwaeij2USx0hvJvc5CFn6cTGFN4I=; fh=4NbAC/LsuMLI0S0hprUlLSLCiHwg6SCAifhH718Jh0Q=; b=JGK6Ec7YCGlCU6ChUWXoXOpCmLB4KHnwCdQnKFYO5kow2MCntRsNqSc4D1DCFtZWHI f21Xz38Gxb7o6J8PRc7Cp/+XSB66grIrv9Kaj0E1g2DOLp8DVZe3PB4kurtn7z9CaIcN qDO0rVBsjWmJJSSopf/sIg7Uj1ATiFL/NlEmllNSDj90OoFL6aEyq7NS+mXR7qUTgqd9 7U/RaoBAWc+iCYOWYAdPG7Pb3inf3evXKcRTkmboosywKzNekdBT3CVIleSP6mZcd6dt rPsQO0GzJcUdBumvR/k/yrO0vJnDpHpuTYOwqpPMOEhIACv67jtoP62qIS3z2sdxShvS ya7Q==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.sourceforge.net header.s=beta header.b=dMCBm3EU; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=HzJIz5xQ; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=IDLZX885; 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 586e51a60fabf-3eca1b65497si3404034fac.1186.2025.11.26.02.34.40 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 26 Nov 2025 02:34:40 -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=dMCBm3EU; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=HzJIz5xQ; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=IDLZX885; 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=C6Ws8sEymFofQUIxwaeij2USx0hvJvc5CFn6cTGFN4I=; b=dMCBm3EUXEVUyU0B1QWP+dqscZ GXeyX+VhoSe23E6CZ95NfFIgQqgBQGFgaAwb7d/w2zXf1bv6miropjczV6oC6A+fOHwdRraWbuaoL cS/OaGJD0NRIilDL8iF2LzWh/A0SVHAAYqAKNAIBWeaZ2iPUGNjlIZp7BahEMvOMlC9g=; 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 1vOCr7-0004s0-Ch; Wed, 26 Nov 2025 10:34:37 +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 1vOCr6-0004ru-Ho for openvpn-devel@lists.sourceforge.net; Wed, 26 Nov 2025 10:34:36 +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=1OFQ6FhDB+Q5shZb+ZY5l2baca+zIZ/P47y3OVVPo6U=; b=HzJIz5xQEOsM6VS1HZqXDqSXSU GdyKOevtAbEp6gSNTKRouY2ilVHytWyG7R3FY6n+LOLhgUTjL31+HZmJXq+oenBetSb1BxjJIo4Mt FXtoAGBvVEF7y3DaAVf1dEVG/9fS9G7v3M3WiwighxuNPDPGADsXvc2EwN16duWxgMrc=; 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=1OFQ6FhDB+Q5shZb+ZY5l2baca+zIZ/P47y3OVVPo6U=; b=IDLZX885ZoLo/XprrGcWXpwnIw lZ/kZlUmKSB39LTDXSX3bTqrD6Z/SrFOyKfrEn/GOajQH8+WFA+fszAEJrgIQKz6I1Y31YoU97wwv qf2a4kxBdeJsUnJpfODt9AwgZie8MAOftv1hfgKwbWbda9Lvqx+i2BweAE5NlXTTq68o=; Received: from [193.149.48.134] (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 1vOCr5-0005z4-4g for openvpn-devel@lists.sourceforge.net; Wed, 26 Nov 2025 10:34:36 +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 5AQAYRqQ004101 for ; Wed, 26 Nov 2025 11:34:27 +0100 Received: (from gert@localhost) by blue.greenie.muc.de (8.18.1/8.18.1/Submit) id 5AQAYRpe004099 for openvpn-devel@lists.sourceforge.net; Wed, 26 Nov 2025 11:34:27 +0100 From: Gert Doering To: openvpn-devel@lists.sourceforge.net Date: Wed, 26 Nov 2025 11:34:21 +0100 Message-ID: <20251126103427.4085-1-gert@greenie.muc.de> X-Mailer: git-send-email 2.51.2 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: Heiko Hund To keep track of how much of the buffer is already used, the difference of the current position and the start of the buffer needs to be multiplied with the size of a character / glyph to bet the byte [...] 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: 1vOCr5-0005z4-4g Subject: [Openvpn-devel] [PATCH v2] iservice: fix calculation of converted domains size 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?1849848789778870890?= X-GMAIL-MSGID: =?utf-8?q?1849848789778870890?= From: Heiko Hund To keep track of how much of the buffer is already used, the difference of the current position and the start of the buffer needs to be multiplied with the size of a character / glyph to bet the byte count, with which calculations are done further down below. Reported-by: Marc Heuse Reported-by: stephan@srlabs.de Change-Id: I16f9426e57f4802ba038ab51f5b70161464b9428 Signed-off-by: Heiko Hund Acked-by: Gert Doering Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1390 --- 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/+/1390 This mail reflects revision 2 of this Change. Acked-by according to Gerrit (reflected above): Gert Doering diff --git a/src/openvpnserv/interactive.c b/src/openvpnserv/interactive.c index 07ca7c9..9c533c1 100644 --- a/src/openvpnserv/interactive.c +++ b/src/openvpnserv/interactive.c @@ -2181,8 +2181,11 @@ *comma = '\0'; } - /* Ignore itf domains which match a pushed search domain */ size_t domain_len = wcslen(pos); + size_t domain_size = domain_len * one_glyph; + size_t converted_size = (pos - domains) * one_glyph; + + /* Ignore itf domains which match a pushed search domain */ if (ListContainsDomain(search_domains, pos, domain_len)) { if (comma) @@ -2199,11 +2202,14 @@ } } - /* Check for enough space to convert this domain */ - domain_len += 1; /* leading dot */ - size_t converted_size = pos - domains; - size_t domain_size = domain_len * one_glyph; + /* Add space for the leading dot */ + domain_len += 1; + domain_size += one_glyph; + + /* Space for the terminating zeros */ size_t extra_size = 2 * one_glyph; + + /* Check for enough space to convert this domain */ if (converted_size + domain_size + extra_size > buf_size) { /* Domain doesn't fit, bad luck if it's the first one */