]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
apply the 0 byte udp packet DoS fix from nuq.
authortaniwha <taniwha@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 30 Nov 2000 17:07:00 +0000 (17:07 +0000)
committertaniwha <taniwha@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 30 Nov 2000 17:07:00 +0000 (17:07 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@118 d7cf8633-e32d-0410-b094-e92efae38249

net_udp.c
net_wins.c

index ae384e1775056b029af412da6f193b970d3263fc..d98ed0ff3f914bc7fc4c4a8dea80516b739e694a 100644 (file)
--- a/net_udp.c
+++ b/net_udp.c
@@ -229,6 +229,9 @@ int UDP_Connect (int socket, struct qsockaddr *addr)
 int UDP_CheckNewConnections (void)
 {
        unsigned long   available;
+       struct sockaddr_in      from;
+       socklen_t                       fromlen;
+       char buff[1];
 
        if (net_acceptsocket == -1)
                return -1;
@@ -237,6 +240,7 @@ int UDP_CheckNewConnections (void)
                Sys_Error ("UDP: ioctlsocket (FIONREAD) failed\n");
        if (available)
                return net_acceptsocket;
+       recvfrom (net_acceptsocket, buff, 0, 0, &from, &fromlen);
        return -1;
 }
 
index 0d5265ed4657df7b6f5a4d26aca726e11bb25e67..87a75eed9519609c1c1c616ab72192a8bb152c16 100644 (file)
@@ -385,7 +385,7 @@ int WINS_CheckNewConnections (void)
        if (net_acceptsocket == -1)
                return -1;
 
-       if (precvfrom (net_acceptsocket, buf, sizeof(buf), MSG_PEEK, NULL, NULL) > 0)
+       if (precvfrom (net_acceptsocket, buf, sizeof(buf), MSG_PEEK, NULL, NULL) >= 0)
        {
                return net_acceptsocket;
        }