]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
Avoid illegal memory access when malformed data is read from the pipe
authorSelva Nair <selva.nair@gmail.com>
Fri, 20 Oct 2017 17:25:56 +0000 (13:25 -0400)
committerGert Doering <gert@greenie.muc.de>
Fri, 3 Nov 2017 18:21:06 +0000 (19:21 +0100)
- If only 1 byte is read from the interactive service client pipe, that
  evaluates to zero wide characters and subsequent check for NUL
  termination in the data buffer segfaults.
  Fix: reject clients that send less than a complete wide character.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1508520356-18277-1-git-send-email-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg15657.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
src/openvpnserv/interactive.c

index b4a3d5c31dcba87303da3724930b0d14b1509d3c..0c91199a86533ba83930ae95a5f39e6ce048531c 100644 (file)
@@ -466,6 +466,13 @@ GetStartupData(HANDLE pipe, STARTUP_DATA *sud)
     }
 
     size = bytes / sizeof(*data);
+    if (size == 0)
+    {
+        MsgToEventLog(M_SYSERR, TEXT("malformed startup data: 1 byte received"));
+        ReturnError(pipe, ERROR_STARTUP_DATA, L"GetStartupData", 1, &exit_event);
+        goto out;
+    }
+
     data = malloc(bytes);
     if (data == NULL)
     {