Skip to contentSkip to conversation

Change in openvpn[master]: win: fix collecting DNS exclude domains

Openvpn-devel In review d12fk (Code Review) 2 participants 8 messages May 20, 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.1747725275000.Ie3fcd845344fd0c3ce9a2f99612fb19fe5ebb2f1@...2715...

#1 lore raw

Attention is currently required from: flichtenheld, plaisthos.

Hello plaisthos, flichtenheld,

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

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

to review the following change.

Change subject: win: fix collecting DNS exclude domains
......................................................................

win: fix collecting DNS exclude domains

The size of the returned MULTI_SZ wide string was calculated wrongly. Instead of adding the size of a WCHAR, only the size of a char was used. As a result, the domains string was stored too short and was missing the final string terminator.

Fixes OpenVPN/openvpn#747
Change-Id Ie3fcd845344fd0c3ce9a2f99612fb19fe5ebb2f1

---
M src/openvpnserv/interactive.c

1 file changed, 3 insertions(+), 3 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/28/1028/1

src/openvpnserv/interactive.c +3 -3
index a1581a6..66afb7b 100644
@@ -2226,7 +2226,7 @@
                     {
                         /* This was the last domain */
                         *pos = '\0';
-                        *size += 1;
+                        *size += one_glyph;
                         return wcslen(domains) ? NO_ERROR : ERROR_FILE_NOT_FOUND;
                     }
                 }
@@ -2248,13 +2248,13 @@
                 memmove(pos + 1, pos, buf_size - converted_size - one_glyph);
                 domains[buf_len - 1] = '\0';
                 *pos = '.';
-                *size += 1;
+                *size += one_glyph;
 
                 if (!comma)
                 {
                     /* Conversion is done */
                     *(pos + domain_len) = '\0';
-                    *size += 1;
+                    *size += one_glyph;
                     return NO_ERROR;
                 }
 

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

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

#2 lore raw

[Openvpn-devel] [XS] Change in openvpn[master]: win: fix collecting DNS exclude data

In reply to a message not in the archive

Attention is currently required from: flichtenheld, plaisthos.

Hello flichtenheld, plaisthos,

I'd like you to reexamine a change. Please visit

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

to look at the new patch set (#2).

Change subject: win: fix collecting DNS exclude data
......................................................................

win: fix collecting DNS exclude data

The size of the returned MULTI_SZ wide domains string was calculated wrongly. Instead of adding the size of a WCHAR, only the size of a char was used. As a result, the domains string was stored too short and was missing the final string terminator.

DHCP assigned DNS server addresses are separated by space, not comma. These spaces were not replaced by semicolon, as the spec requires.

Fixes OpenVPN/openvpn#747
Change-Id Ie3fcd845344fd0c3ce9a2f99612fb19fe5ebb2f1

---
M src/openvpnserv/interactive.c

1 file changed, 4 insertions(+), 4 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/28/1028/2

src/openvpnserv/interactive.c +4 -4
index a1581a6..4b6c8b6 100644
@@ -2226,7 +2226,7 @@
                     {
                         /* This was the last domain */
                         *pos = '\0';
-                        *size += 1;
+                        *size += one_glyph;
                         return wcslen(domains) ? NO_ERROR : ERROR_FILE_NOT_FOUND;
                     }
                 }
@@ -2248,13 +2248,13 @@
                 memmove(pos + 1, pos, buf_size - converted_size - one_glyph);
                 domains[buf_len - 1] = '\0';
                 *pos = '.';
-                *size += 1;
+                *size += one_glyph;
 
                 if (!comma)
                 {
                     /* Conversion is done */
                     *(pos + domain_len) = '\0';
-                    *size += 1;
+                    *size += one_glyph;
                     return NO_ERROR;
                 }
 
@@ -2412,7 +2412,7 @@
             /* Replace comma-delimters with semicolons, as required by NRPT */
             for (int j = 0; j < sizeof(data[0].addresses) && data[i].addresses[j]; j++)
             {
-                if (data[i].addresses[j] == ',')
+                if (data[i].addresses[j] == ',' || data[i].addresses[j] == ' ')
                 {
                     data[i].addresses[j] = ';';
                 }

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

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ie3fcd845344fd0c3ce9a2f99612fb19fe5ebb2f1
Gerrit-Change-Number: 1028
Gerrit-PatchSet: 2
Gerrit-Owner: d12fk <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-MessageType: newpatchset

#3 lore raw

[Openvpn-devel] [S] Change in openvpn[master]: win: fix collecting DNS exclude data

In reply to a message not in the archive

Attention is currently required from: flichtenheld, plaisthos.

Hello flichtenheld, plaisthos,

I'd like you to reexamine a change. Please visit

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

to look at the new patch set (#3).

Change subject: win: fix collecting DNS exclude data
......................................................................

win: fix collecting DNS exclude data

The size of the returned MULTI_SZ wide domains string was calculated wrongly. Instead of adding the size of a WCHAR, only the size of a char was used. As a result, the domains string was stored too short and was missing the final string terminator.

DHCP assigned DNS server addresses are separated by space, not comma. These spaces were not replaced by semicolon, as the spec requires.

Fixes OpenVPN/openvpn#747
Change-Id Ie3fcd845344fd0c3ce9a2f99612fb19fe5ebb2f1

---
M src/openvpnserv/interactive.c

1 file changed, 5 insertions(+), 5 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/28/1028/3

src/openvpnserv/interactive.c +5 -5
index a1581a6..bea8277 100644
@@ -2226,7 +2226,7 @@
                     {
                         /* This was the last domain */
                         *pos = '\0';
-                        *size += 1;
+                        *size += one_glyph;
                         return wcslen(domains) ? NO_ERROR : ERROR_FILE_NOT_FOUND;
                     }
                 }
@@ -2248,13 +2248,13 @@
                 memmove(pos + 1, pos, buf_size - converted_size - one_glyph);
                 domains[buf_len - 1] = '\0';
                 *pos = '.';
-                *size += 1;
+                *size += one_glyph;
 
                 if (!comma)
                 {
                     /* Conversion is done */
                     *(pos + domain_len) = '\0';
-                    *size += 1;
+                    *size += one_glyph;
                     return NO_ERROR;
                 }
 
@@ -2409,10 +2409,10 @@
 
         if (v4_addrs_size || v6_addrs_size)
         {
-            /* Replace comma-delimters with semicolons, as required by NRPT */
+            /* Replace delimters with semicolons, as required by NRPT */
             for (int j = 0; j < sizeof(data[0].addresses) && data[i].addresses[j]; j++)
             {
-                if (data[i].addresses[j] == ',')
+                if (data[i].addresses[j] == ',' || data[i].addresses[j] == ' ')
                 {
                     data[i].addresses[j] = ';';
                 }

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

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ie3fcd845344fd0c3ce9a2f99612fb19fe5ebb2f1
Gerrit-Change-Number: 1028
Gerrit-PatchSet: 3
Gerrit-Owner: d12fk <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-MessageType: newpatchset

#4 lore raw

[Openvpn-devel] [S] Change in openvpn[master]: win: fix collecting DNS exclude data

In reply to a message not in the archive

Attention is currently required from: d12fk, flichtenheld, plaisthos.

stipa has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/1028?usp=email )

Change subject: win: fix collecting DNS exclude data
......................................................................

Patch Set 3: Code-Review+2

(1 comment)

Patchset:

PS3:
Tested on Windows 11. Wi-Fi adapter with connection-specific DNS suffix and 2 DNS servers pushed by DHCP. Everything works - One NRPT rule created for "." domain and another one (exclusion rule) for ".panoulu.local" domain. The first rule directs all DNS queries to VPN-pushed DNS server and the second directs queries to ".panoulu.local" to WiFi-adapter DNS servers. Checked created registry entries and DNS queries in Wireshark. Code looks good.

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

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ie3fcd845344fd0c3ce9a2f99612fb19fe5ebb2f1
Gerrit-Change-Number: 1028
Gerrit-PatchSet: 3
Gerrit-Owner: d12fk <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-Reviewer: stipa <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: d12fk <[email protected]...>
Gerrit-Comment-Date: Tue, 20 May 2025 08:48:09 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment

#5 lore raw

PATCH v3 1/1 win: fix collecting DNS exclude data

In reply to a message not in the archive

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

The size of the returned MULTI_SZ wide domains string was calculated wrongly. Instead of adding the size of a WCHAR, only the size of a char was used. As a result, the domains string was stored too short and was missing the final string terminator.

DHCP assigned DNS server addresses are separated by space, not comma. These spaces were not replaced by semicolon, as the spec requires.

Fixes OpenVPN/openvpn#747
Change-Id Ie3fcd845344fd0c3ce9a2f99612fb19fe5ebb2f1

---

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

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

src/openvpnserv/interactive.c +5 -5
index a1581a6..bea8277 100644
@@ -2226,7 +2226,7 @@
                     {
                         /* This was the last domain */
                         *pos = '\0';
-                        *size += 1;
+                        *size += one_glyph;
                         return wcslen(domains) ? NO_ERROR : ERROR_FILE_NOT_FOUND;
                     }
                 }
@@ -2248,13 +2248,13 @@
                 memmove(pos + 1, pos, buf_size - converted_size - one_glyph);
                 domains[buf_len - 1] = '\0';
                 *pos = '.';
-                *size += 1;
+                *size += one_glyph;
 
                 if (!comma)
                 {
                     /* Conversion is done */
                     *(pos + domain_len) = '\0';
-                    *size += 1;
+                    *size += one_glyph;
                     return NO_ERROR;
                 }
 
@@ -2409,10 +2409,10 @@
 
         if (v4_addrs_size || v6_addrs_size)
         {
-            /* Replace comma-delimters with semicolons, as required by NRPT */
+            /* Replace delimters with semicolons, as required by NRPT */
             for (int j = 0; j < sizeof(data[0].addresses) && data[i].addresses[j]; j++)
             {
-                if (data[i].addresses[j] == ',')
+                if (data[i].addresses[j] == ',' || data[i].addresses[j] == ' ')
                 {
                     data[i].addresses[j] = ';';
                 }
#6 lore raw

[Openvpn-devel] [PATCH applied] Re: win: fix collecting DNS exclude data

Explanation sounds very logical, code looks reasonable, and Lev has verified that the NRPT exclude domains stuff indeed works now if multiple domains are involved. Great :-)

Your patch has been applied to the master branch.

commit 21c8f820d15e7891b042d33cdd989316ed987dab

Author: Heiko Hund
Date:   Tue May 20 10:55:06 2025 +0200
     win: fix collecting DNS exclude data

     Signed-off-by: Heiko Hund <[email protected]...>
     Acked-by: Lev Stipakov <[email protected]...>
     Message-Id: <[email protected]...>
     URL: https://www.mail-archive.com/[email protected]/msg31727.html
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering

#7 lore raw

[Openvpn-devel] [S] Change in openvpn[master]: win: fix collecting DNS exclude data

In reply to a message not in the archive

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

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

Change subject: win: fix collecting DNS exclude data
......................................................................

win: fix collecting DNS exclude data

The size of the returned MULTI_SZ wide domains string was calculated wrongly. Instead of adding the size of a WCHAR, only the size of a char was used. As a result, the domains string was stored too short and was missing the final string terminator.

DHCP assigned DNS server addresses are separated by space, not comma. These spaces were not replaced by semicolon, as the spec requires.

Github: fixes OpenVPN/openvpn#747

Change-Id Ie3fcd845344fd0c3ce9a2f99612fb19fe5ebb2f1

Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg31727.html

---
M src/openvpnserv/interactive.c

1 file changed, 5 insertions(+), 5 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/28/1028/4

src/openvpnserv/interactive.c +5 -5
index a1581a6..6681b7c 100644
@@ -2226,7 +2226,7 @@
                     {
                         /* This was the last domain */
                         *pos = '\0';
-                        *size += 1;
+                        *size += one_glyph;
                         return wcslen(domains) ? NO_ERROR : ERROR_FILE_NOT_FOUND;
                     }
                 }
@@ -2248,13 +2248,13 @@
                 memmove(pos + 1, pos, buf_size - converted_size - one_glyph);
                 domains[buf_len - 1] = '\0';
                 *pos = '.';
-                *size += 1;
+                *size += one_glyph;
 
                 if (!comma)
                 {
                     /* Conversion is done */
                     *(pos + domain_len) = '\0';
-                    *size += 1;
+                    *size += one_glyph;
                     return NO_ERROR;
                 }
 
@@ -2409,10 +2409,10 @@
 
         if (v4_addrs_size || v6_addrs_size)
         {
-            /* Replace comma-delimters with semicolons, as required by NRPT */
+            /* Replace delimiters with semicolons, as required by NRPT */
             for (int j = 0; j < sizeof(data[0].addresses) && data[i].addresses[j]; j++)
             {
-                if (data[i].addresses[j] == ',')
+                if (data[i].addresses[j] == ',' || data[i].addresses[j] == ' ')
                 {
                     data[i].addresses[j] = ';';
                 }

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

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ie3fcd845344fd0c3ce9a2f99612fb19fe5ebb2f1
Gerrit-Change-Number: 1028
Gerrit-PatchSet: 4
Gerrit-Owner: d12fk <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-Reviewer: stipa <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-MessageType: newpatchset

#8 lore raw

[Openvpn-devel] [S] Change in openvpn[master]: win: fix collecting DNS exclude data

In reply to a message not in the archive

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

Change subject: win: fix collecting DNS exclude data
......................................................................

win: fix collecting DNS exclude data

The size of the returned MULTI_SZ wide domains string was calculated wrongly. Instead of adding the size of a WCHAR, only the size of a char was used. As a result, the domains string was stored too short and was missing the final string terminator.

DHCP assigned DNS server addresses are separated by space, not comma. These spaces were not replaced by semicolon, as the spec requires.

Github: fixes OpenVPN/openvpn#747

Change-Id Ie3fcd845344fd0c3ce9a2f99612fb19fe5ebb2f1

Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg31727.html

---
M src/openvpnserv/interactive.c

1 file changed, 5 insertions(+), 5 deletions(-)
src/openvpnserv/interactive.c +5 -5
index a1581a6..6681b7c 100644
@@ -2226,7 +2226,7 @@
                     {
                         /* This was the last domain */
                         *pos = '\0';
-                        *size += 1;
+                        *size += one_glyph;
                         return wcslen(domains) ? NO_ERROR : ERROR_FILE_NOT_FOUND;
                     }
                 }
@@ -2248,13 +2248,13 @@
                 memmove(pos + 1, pos, buf_size - converted_size - one_glyph);
                 domains[buf_len - 1] = '\0';
                 *pos = '.';
-                *size += 1;
+                *size += one_glyph;
 
                 if (!comma)
                 {
                     /* Conversion is done */
                     *(pos + domain_len) = '\0';
-                    *size += 1;
+                    *size += one_glyph;
                     return NO_ERROR;
                 }
 
@@ -2409,10 +2409,10 @@
 
         if (v4_addrs_size || v6_addrs_size)
         {
-            /* Replace comma-delimters with semicolons, as required by NRPT */
+            /* Replace delimiters with semicolons, as required by NRPT */
             for (int j = 0; j < sizeof(data[0].addresses) && data[i].addresses[j]; j++)
             {
-                if (data[i].addresses[j] == ',')
+                if (data[i].addresses[j] == ',' || data[i].addresses[j] == ' ')
                 {
                     data[i].addresses[j] = ';';
                 }

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

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ie3fcd845344fd0c3ce9a2f99612fb19fe5ebb2f1
Gerrit-Change-Number: 1028
Gerrit-PatchSet: 4
Gerrit-Owner: d12fk <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-Reviewer: stipa <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-MessageType: merged