Attention is currently required from: Arne Schwabe.

Hello Arne Schwabe,

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

    https://gerrit.openvpn.net/c/openvpn/+/2373?usp=email

to review the following change.


Change subject: openvpnserv: read the whole SearchList in HasValidSearchList()
......................................................................

openvpnserv: read the whole SearchList in HasValidSearchList()

SearchList was read into a 64 byte buffer, and on ERROR_MORE_DATA the
buffer, whose contents are undefined then, was scanned anyway. A search
list longer than 63 characters was therefore found valid or not at
random, and the VPN domains could be added to the interface list, which
the system list overrides.

Query the size first and read the value into a buffer that fits it.
Also cast to unsigned char for isalnum().

Broken since ae90cbad ("dns: support multiple domains without DHCP").

Change-Id: I73dc52dcc1196b57d672ff2303380f5ec9215a43
Signed-off-by: Razvan Cojocaru <[email protected]>
---
M src/openvpnserv/interactive.c
1 file changed, 23 insertions(+), 9 deletions(-)



  git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/73/2373/1

diff --git a/src/openvpnserv/interactive.c b/src/openvpnserv/interactive.c
index 240aeaf..2d18f11 100644
--- a/src/openvpnserv/interactive.c
+++ b/src/openvpnserv/interactive.c
@@ -1290,21 +1290,35 @@
 static BOOL
 HasValidSearchList(HKEY key)
 {
-    char data[64];
-    DWORD size = sizeof(data);
-    LSTATUS err = RegGetValueA(key, NULL, "SearchList", RRF_RT_REG_SZ, NULL, 
(PBYTE)data, &size);
-    if (!err || err == ERROR_MORE_DATA)
+    DWORD size = 0;
+    LSTATUS err = RegGetValueA(key, NULL, "SearchList", RRF_RT_REG_SZ, NULL, 
NULL, &size);
+    if (err || size == 0)
     {
-        data[sizeof(data) - 1] = '\0';
-        for (size_t i = 0; i < strlen(data); ++i)
+        return FALSE;
+    }
+
+    char *data = malloc(size);
+    if (!data)
+    {
+        return FALSE;
+    }
+
+    BOOL ret = FALSE;
+    err = RegGetValueA(key, NULL, "SearchList", RRF_RT_REG_SZ, NULL, 
(PBYTE)data, &size);
+    if (!err)
+    {
+        for (size_t i = 0; data[i]; ++i)
         {
-            if (isalnum(data[i]) || data[i] == '-' || data[i] == '.')
+            if (isalnum((unsigned char)data[i]) || data[i] == '-' || data[i] 
== '.')
             {
-                return TRUE;
+                ret = TRUE;
+                break;
             }
         }
     }
-    return FALSE;
+
+    free(data);
+    return ret;
 }

 /**

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

Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I73dc52dcc1196b57d672ff2303380f5ec9215a43
Gerrit-Change-Number: 2373
Gerrit-PatchSet: 1
Gerrit-Owner: Răzvan Cojocaru <[email protected]>
Gerrit-Reviewer: Arne Schwabe <[email protected]>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: Arne Schwabe <[email protected]>
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

Reply via email to