[TCPIP] Check buffer before dereferencing it
authorPierre Schweitzer <pierre@reactos.org>
Tue, 1 Jan 2019 09:45:48 +0000 (10:45 +0100)
committerPierre Schweitzer <pierre@reactos.org>
Tue, 1 Jan 2019 09:45:48 +0000 (10:45 +0100)
CID 716664

drivers/network/tcpip/tcpip/ninfo.c

index cb88a21..5c0952b 100644 (file)
@@ -312,13 +312,13 @@ TDI_STATUS InfoTdiSetRoute(PIP_INTERFACE IF, PVOID Buffer, UINT BufferSize)
     IP_ADDRESS Address, Netmask, Router;
     PIPROUTE_ENTRY Route = Buffer;
 
+    if (!Buffer || BufferSize < sizeof(IPROUTE_ENTRY))
+        return TDI_INVALID_PARAMETER;
+
     AddrInitIPv4( &Address, Route->Dest );
     AddrInitIPv4( &Netmask, Route->Mask );
     AddrInitIPv4( &Router,  Route->Gw );
 
-    if (!Buffer || BufferSize < sizeof(IPROUTE_ENTRY))
-        return TDI_INVALID_PARAMETER;
-
     if (IF == Loopback)
     {
         DbgPrint("Failing attempt to add route to loopback adapter\n");