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>
| ... | ... |
@@ -2226,7 +2226,7 @@ GetItfDnsDomains(HKEY itf, PCWSTR search_domains, PWSTR domains, PDWORD size) |
| 2226 | 2226 |
{
|
| 2227 | 2227 |
/* This was the last domain */ |
| 2228 | 2228 |
*pos = '\0'; |
| 2229 |
- *size += 1; |
|
| 2229 |
+ *size += one_glyph; |
|
| 2230 | 2230 |
return wcslen(domains) ? NO_ERROR : ERROR_FILE_NOT_FOUND; |
| 2231 | 2231 |
} |
| 2232 | 2232 |
} |
| ... | ... |
@@ -2248,13 +2248,13 @@ GetItfDnsDomains(HKEY itf, PCWSTR search_domains, PWSTR domains, PDWORD size) |
| 2248 | 2248 |
memmove(pos + 1, pos, buf_size - converted_size - one_glyph); |
| 2249 | 2249 |
domains[buf_len - 1] = '\0'; |
| 2250 | 2250 |
*pos = '.'; |
| 2251 |
- *size += 1; |
|
| 2251 |
+ *size += one_glyph; |
|
| 2252 | 2252 |
|
| 2253 | 2253 |
if (!comma) |
| 2254 | 2254 |
{
|
| 2255 | 2255 |
/* Conversion is done */ |
| 2256 | 2256 |
*(pos + domain_len) = '\0'; |
| 2257 |
- *size += 1; |
|
| 2257 |
+ *size += one_glyph; |
|
| 2258 | 2258 |
return NO_ERROR; |
| 2259 | 2259 |
} |
| 2260 | 2260 |
|
| ... | ... |
@@ -2409,10 +2409,10 @@ GetNrptExcludeData(PCWSTR search_domains, nrpt_exclude_data_t *data, size_t data |
| 2409 | 2409 |
|
| 2410 | 2410 |
if (v4_addrs_size || v6_addrs_size) |
| 2411 | 2411 |
{
|
| 2412 |
- /* Replace comma-delimters with semicolons, as required by NRPT */ |
|
| 2412 |
+ /* Replace delimiters with semicolons, as required by NRPT */ |
|
| 2413 | 2413 |
for (int j = 0; j < sizeof(data[0].addresses) && data[i].addresses[j]; j++) |
| 2414 | 2414 |
{
|
| 2415 |
- if (data[i].addresses[j] == ',') |
|
| 2415 |
+ if (data[i].addresses[j] == ',' || data[i].addresses[j] == ' ') |
|
| 2416 | 2416 |
{
|
| 2417 | 2417 |
data[i].addresses[j] = ';'; |
| 2418 | 2418 |
} |