fix the 0 byte udp packet DoS bug (for linux, anyway: mods from ProQuake

applied for windows, but I can't test).

In, linux, the problem was caused by nuq checking to see if there were any
bytes to be read and if there were 0 bytes, just carying on without reading
anything. It seems that the 0 byte packet was blocking the queue and so a 0
byte recvfrom is needed to make sure it gets removed.
This commit is contained in:
Bill Currie 2000-11-24 20:36:37 +00:00
parent 9a53a2d328
commit c8483de74f
3 changed files with 6 additions and 2 deletions

View file

@ -262,7 +262,7 @@ int MPATH_CheckNewConnections (void)
if (net_acceptsocket == -1)
return -1;
if (recvfrom (net_acceptsocket, buf, 4, MSG_PEEK, NULL, NULL) > 0)
if (recvfrom (net_acceptsocket, buf, 4, MSG_PEEK, NULL, NULL) >= 0)
return net_acceptsocket;
return -1;
}

View file

@ -248,6 +248,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;
@ -256,6 +259,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;
}

View file

@ -393,7 +393,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;
}