From: "cron2 (Code Review)" Date: Wed, 26 Nov 2025 11:01:30 +0000 In-Reply-To: References: Reply-To: gert@...1296..., arne-openvpn@...1227..., heiko@...515..., openvpn-devel@lists.sourceforge.net Message-ID: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="YdgE+UJhbUI="; charset=UTF-8 Subject: [Openvpn-devel] [S] Change in openvpn[master]: iservice: fix calculation of converted domains size List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: d12fk Cc: plaisthos , openvpn-devel --YdgE+UJhbUI= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/13= 90?usp=3Demail ) Change subject: iservice: fix calculation of converted domains size ...................................................................... iservice: fix calculation of converted domains size 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@...2953... Change-Id: I16f9426e57f4802ba038ab51f5b70161464b9428 Signed-off-by: Heiko Hund Acked-by: Gert Doering Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1390 Message-Id: <20251126103427.4085-1-gert@...1296...> Signed-off-by: Gert Doering --- M src/openvpnserv/interactive.c 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/openvpnserv/interactive.c b/src/openvpnserv/interactive.c index dbb5a4b..ed3c928 100644 --- a/src/openvpnserv/interactive.c +++ b/src/openvpnserv/interactive.c @@ -2181,8 +2181,11 @@ *comma =3D '\0'; } - /* Ignore itf domains which match a pushed search domain */ size_t domain_len =3D wcslen(pos); + size_t domain_size =3D domain_len * one_glyph; + size_t converted_size =3D (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 +=3D 1; /* leading dot */ - size_t converted_size =3D pos - domains; - size_t domain_size =3D domain_len * one_glyph; + /* Add space for the leading dot */ + domain_len +=3D 1; + domain_size +=3D one_glyph; + + /* Space for the terminating zeros */ size_t extra_size =3D 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 = */ -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/1390?usp=3Demail To unsubscribe, or for help writing mail filters, visit http://gerrit.openv= pn.net/settings?usp=3Demail Gerrit-MessageType: merged Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: I16f9426e57f4802ba038ab51f5b70161464b9428 Gerrit-Change-Number: 1390 Gerrit-PatchSet: 3 Gerrit-Owner: d12fk Gerrit-Reviewer: cron2 Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel --YdgE+UJhbUI= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

cron2 sub= mitted this change.

View Change

iservice: fix calculation of converted domains s=
ize

To keep track of how much of the buffer is already used, the dif= ference
of the current position and the start of the buffer needs to be<= br>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 <marc@...2953...>
Reported-by: stephan@...2953...
Ch= ange-Id: I16f9426e57f4802ba038ab51f5b70161464b9428
Signed-off-by: Heiko = Hund <heiko@...2662...>
Acked-by: Gert Doering <gert@...1296...= >
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1390
Message-= Id: <20251126103427.4085-1-gert@...1296...>
Signed-off-by: Gert Do= ering <gert@...1296...>
---
M src/openvpnserv/interactive.c
= 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/src/openvpnserv/interactive.c b/src/openvpnserv/interactive=
.c
index dbb5a4b..ed3c928 100644
--- a/src/= openvpnserv/interactive.c
+++ b/src/openvpnserv/interactive= .c
@@ -2181,8 +2181,11 @@
= *comma =3D '\0';
}
<= span>
- = /* Ignore itf domains which match a pushed search domain */
size_t domain_len =3D wcslen(pos);
+ size_t domain_size =3D do= main_len * one_glyph;
+ size_t converted_size =3D (pos - domains) * one_glyph;
+
+ /* Ignore itf domains whi= ch match a pushed search domain */
if (Lis= tContainsDomain(search_domains, pos, domain_len))
= {
if (comma)
@= @ -2199,11 +2202,14 @@
}
}


- /* Check for enough space to convert this= domain */
- = domain_len +=3D 1; /* leading dot */
- size_t converted_size =3D pos - domains= ;
- size= _t domain_size =3D domain_len * one_glyph;
+ /* Add space for the leading dot */<= /span>
+ doma= in_len +=3D 1;
+ = domain_size +=3D one_glyph;
+
+= /* Space for the terminating zeros */
= size_t extra_size =3D 2 * one_glyph;
+
+ /* Check for enough space to convert this domain = */
if (converted_size + domain_size + extr= a_size > buf_size)
{
= /* Domain doesn't fit, bad luck if it's the firs= t one */

To view, visit change 1390. To uns= ubscribe, or for help writing mail filters, visit settings.

Gerrit-MessageType: merged
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I16f9426e57f4802ba038ab51f5b= 70161464b9428
Gerrit-Change-Number: 1390
Gerrit-PatchSet: 3
Gerrit-Owner: d12fk <heiko@...515...>
Gerrit-Reviewer: cron2 <gert@...1296...>=
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...= .1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
= --YdgE+UJhbUI=--