]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
win: fix collecting DNS exclude data
authorHeiko Hund <heiko@ist.eigentlich.net>
Tue, 20 May 2025 08:55:06 +0000 (10:55 +0200)
committerGert Doering <gert@greenie.muc.de>
Tue, 20 May 2025 12:08:36 +0000 (14:08 +0200)
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
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>
src/openvpnserv/interactive.c

index a1581a6685af8f80778bf5ca3ad41790f0779ade..6681b7cad8d85e0a5544cb6720bfed65834c8165 100644 (file)
@@ -2226,7 +2226,7 @@ GetItfDnsDomains(HKEY itf, PCWSTR search_domains, PWSTR domains, PDWORD size)
                     {
                         /* 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 @@ GetItfDnsDomains(HKEY itf, PCWSTR search_domains, PWSTR domains, PDWORD size)
                 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 @@ GetNrptExcludeData(PCWSTR search_domains, nrpt_exclude_data_t *data, size_t data
 
         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] = ';';
                 }