[Openvpn-devel,v3] win: fix collecting DNS exclude data

Message ID 20250520085513.28213-1-gert@greenie.muc.de
State Accepted
Headers show
Series [Openvpn-devel,v3] win: fix collecting DNS exclude data | expand

Commit Message

Gert Doering May 20, 2025, 8:55 a.m. UTC
From: Heiko Hund <heiko@ist.eigentlich.net>

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
Signed-off-by: Heiko Hund <heiko@ist.eigentlich.net>
Acked-by: Lev Stipakov <lstipakov@gmail.com>
---

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 <lstipakov@gmail.com>

Comments

Gert Doering May 20, 2025, 12:09 p.m. UTC | #1
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 <heiko@ist.eigentlich.net>
     Acked-by: Lev Stipakov <lstipakov@gmail.com>
     Message-Id: <20250520085513.28213-1-gert@greenie.muc.de>
     URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg31727.html
     Signed-off-by: Gert Doering <gert@greenie.muc.de>


--
kind regards,

Gert Doering

Patch

diff --git a/src/openvpnserv/interactive.c b/src/openvpnserv/interactive.c
index a1581a6..bea8277 100644
--- a/src/openvpnserv/interactive.c
+++ b/src/openvpnserv/interactive.c
@@ -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] = ';';
                 }