Drop packets from ports under <1024 (server only). Also drop packets

with invalid source address (broadcast and any).
This commit is contained in:
Dabb 2001-01-08 17:47:38 +00:00
parent e2f1f503ef
commit e32fb4d048

View file

@ -249,6 +249,7 @@ NET_GetPacket (void)
int ret;
struct sockaddr_in from;
socklen_t fromlen;
int i;
fromlen = sizeof (from);
ret =
@ -258,6 +259,7 @@ NET_GetPacket (void)
SockadrToNetadr (&from, &net_from);
if (ret == -1) {
#ifdef _WIN32
int err = WSAGetLastError ();
@ -283,6 +285,19 @@ NET_GetPacket (void)
return false;
}
// Check for malformed packets
if (is_server && ntohs(net_from.port)<1024) {
Con_Printf ("Warning: Packet from %s dropped: Bad port\n",
NET_AdrToString (net_from));
return false;
}
if (from.sin_addr.s_addr==INADDR_ANY || from.sin_addr.s_addr==INADDR_BROADCAST) {
Con_Printf ("Warning: Packet dropped - bad address\n");
return false;
}
net_message.cursize = ret;
if (ret == sizeof (net_message_buffer)) {
Con_Printf ("Oversize packet from %s\n", NET_AdrToString (net_from));