Skip to contentSkip to conversation

Change in openvpn[master]: iservice: make sure registry string is terminated

Openvpn-devel In review d12fk (Code Review) 2 participants 6 messages Nov 23, 2025 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): gerrit.1763880426000.Icaeca22bdbd8ead0cb12345b1bcc2b5c0f46236f@...2715...

#1 lore raw

Attention is currently required from: plaisthos.

Hello plaisthos,

I'd like you to do a code review.
Please visit

    http://gerrit.openvpn.net/c/openvpn/+/1392?usp=email

to review the following change.

Change subject: iservice: make sure registry string is terminated
......................................................................

iservice: make sure registry string is terminated

When reading the interface domains from the registry, check that the string is zero terminated, since the code in GetItfDnsDomains depends on the fact when doing size calculations during the conversion.

Change-Id Icaeca22bdbd8ead0cb12345b1bcc2b5c0f46236f

---
M src/openvpnserv/interactive.c

1 file changed, 1 insertion(+), 1 deletion(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/92/1392/1

src/openvpnserv/interactive.c +1 -1
index f31a8a9..ec80a30 100644
@@ -2163,7 +2163,7 @@
     {
         *size = buf_size;
         err = RegGetValueW(itf, NULL, values[i], RRF_RT_REG_SZ, NULL, (PBYTE)domains, size);
-        if (!err && *size > one_glyph && wcschr(domains, '.'))
+        if (!err && *size > one_glyph && domains[(*size / one_glyph) - 1] == '\0' && wcschr(domains, '.'))
         {
             /*
              * Found domain(s), now convert them:

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1392?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Icaeca22bdbd8ead0cb12345b1bcc2b5c0f46236f
Gerrit-Change-Number: 1392
Gerrit-PatchSet: 1
Gerrit-Owner: d12fk <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>

#2 lore raw
In reply to a message not in the archive

Attention is currently required from: d12fk, plaisthos.

cron2 has posted comments on this change by d12fk. ( http://gerrit.openvpn.net/c/openvpn/+/1392?usp=email )

Change subject: iservice: make sure registry string is terminated
......................................................................

Patch Set 1: Code-Review+2

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1392?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Icaeca22bdbd8ead0cb12345b1bcc2b5c0f46236f
Gerrit-Change-Number: 1392
Gerrit-PatchSet: 1
Gerrit-Owner: d12fk <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: d12fk <[email protected]...>
Gerrit-Comment-Date: Sun, 23 Nov 2025 11:58:24 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes

#3 lore raw

PATCH 1/1 iservice: make sure registry string is terminated

In reply to a message not in the archive

From: Heiko Hund <[email protected]...>

When reading the interface domains from the registry, check that the string is zero terminated, since the code in GetItfDnsDomains depends on the fact when doing size calculations during the conversion.

Change-Id Icaeca22bdbd8ead0cb12345b1bcc2b5c0f46236f

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1392
---

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/+/1392
This mail reflects revision 1 of this Change.

Acked-by according to Gerrit (reflected above):
Gert Doering <[email protected]...>

src/openvpnserv/interactive.c +1 -1
index f31a8a9..ec80a30 100644
@@ -2163,7 +2163,7 @@
     {
         *size = buf_size;
         err = RegGetValueW(itf, NULL, values[i], RRF_RT_REG_SZ, NULL, (PBYTE)domains, size);
-        if (!err && *size > one_glyph && wcschr(domains, '.'))
+        if (!err && *size > one_glyph && domains[(*size / one_glyph) - 1] == '\0' && wcschr(domains, '.'))
         {
             /*
              * Found domain(s), now convert them:
#4 lore raw

[Openvpn-devel] [PATCH applied] Re: iservice: make sure registry string is terminated

Trivial enough.

Not sure we really *need* this - the documentation for RegGetValueW() states

If the data is a string, the function checks for a terminating null character. If one is not found, the string is stored with a null terminator if the buffer is large enough to accommodate the extra character. Otherwise, the function fails and returns ERROR_MORE_DATA.

which reads to me like "either we get 'err' or it is always null terminated", so the "if (!err)" part would catch this anyway.

I have no way to actually test this beyond "does it compile" - which it does.

Your patch has been applied to the master branch.

commit a1c41b0acb6905506ad35e339396206653fee5cc

Author: Heiko Hund
Date:   Sun Nov 23 12:58:46 2025 +0100
     iservice: make sure registry string is terminated

     Signed-off-by: Heiko Hund <[email protected]...>
     Acked-by: Gert Doering <[email protected]...>
     Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1392
     Message-Id: <[email protected]...>
     URL: https://www.mail-archive.com/[email protected]/msg34610.html
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering

#5 lore raw
In reply to a message not in the archive

cron2 has uploaded a new patch set (#2) to the change originally created by d12fk. ( http://gerrit.openvpn.net/c/openvpn/+/1392?usp=email )

The following approvals got outdated and were removed:
Code-Review+2 by cron2

Change subject: iservice: make sure registry string is terminated
......................................................................

iservice: make sure registry string is terminated

When reading the interface domains from the registry, check that the string is zero terminated, since the code in GetItfDnsDomains depends on the fact when doing size calculations during the conversion.

Change-Id Icaeca22bdbd8ead0cb12345b1bcc2b5c0f46236f

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1392
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg34610.html

---
M src/openvpnserv/interactive.c

1 file changed, 1 insertion(+), 1 deletion(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/92/1392/2

src/openvpnserv/interactive.c +1 -1
index d778e89..860375d 100644
@@ -2163,7 +2163,7 @@
     {
         *size = buf_size;
         err = RegGetValueW(itf, NULL, values[i], RRF_RT_REG_SZ, NULL, (PBYTE)domains, size);
-        if (!err && *size > one_glyph && wcschr(domains, '.'))
+        if (!err && *size > one_glyph && domains[(*size / one_glyph) - 1] == '\0' && wcschr(domains, '.'))
         {
             /*
              * Found domain(s), now convert them:

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1392?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Icaeca22bdbd8ead0cb12345b1bcc2b5c0f46236f
Gerrit-Change-Number: 1392
Gerrit-PatchSet: 2
Gerrit-Owner: d12fk <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>

#6 lore raw
In reply to a message not in the archive

cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/1392?usp=email )

Change subject: iservice: make sure registry string is terminated
......................................................................

iservice: make sure registry string is terminated

When reading the interface domains from the registry, check that the string is zero terminated, since the code in GetItfDnsDomains depends on the fact when doing size calculations during the conversion.

Change-Id Icaeca22bdbd8ead0cb12345b1bcc2b5c0f46236f

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1392
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg34610.html

---
M src/openvpnserv/interactive.c

1 file changed, 1 insertion(+), 1 deletion(-)
src/openvpnserv/interactive.c +1 -1
index d778e89..860375d 100644
@@ -2163,7 +2163,7 @@
     {
         *size = buf_size;
         err = RegGetValueW(itf, NULL, values[i], RRF_RT_REG_SZ, NULL, (PBYTE)domains, size);
-        if (!err && *size > one_glyph && wcschr(domains, '.'))
+        if (!err && *size > one_glyph && domains[(*size / one_glyph) - 1] == '\0' && wcschr(domains, '.'))
         {
             /*
              * Found domain(s), now convert them:

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1392?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: merged
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Icaeca22bdbd8ead0cb12345b1bcc2b5c0f46236f
Gerrit-Change-Number: 1392
Gerrit-PatchSet: 2
Gerrit-Owner: d12fk <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>