mirror of
https://git.code.sf.net/p/quake/newtree
synced 2024-11-10 14:52:08 +00:00
Drop packets from ports under <1024 (server only). Also drop packets
with invalid source address (broadcast and any).
This commit is contained in:
parent
e2f1f503ef
commit
e32fb4d048
1 changed files with 15 additions and 0 deletions
|
@ -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));
|
||||
|
|
Loading…
Reference in a new issue