Treat packets from unknown nodes differently

Instead of trying to decompress packets from unknown connections (and
failing them anyway), they are now reported and discarded without doing
anything else.
This commit is contained in:
Edward Richardson 2014-01-12 18:39:19 +13:00
parent 455145d611
commit 6db974918a
1 changed files with 7 additions and 1 deletions

View File

@ -293,7 +293,7 @@ void PacketGet (void)
return;
}
}
else if (c > 0)
else if (node >= 0 && c > 0)
{
doomcom.data[0] = TransmitBuffer[0] & ~NCMD_COMPRESSED;
if (TransmitBuffer[0] & NCMD_COMPRESSED)
@ -316,6 +316,12 @@ void PacketGet (void)
memcpy(doomcom.data + 1, TransmitBuffer + 1, c - 1);
}
}
else if (c > 0)
{ //The packet is not from any in-game node, so we might as well discard it.
Printf("Dropped packet: Unknown host (%s:%d)\n", inet_ntoa(fromaddress.sin_addr), fromaddress.sin_port);
doomcom.remotenode = -1;
return;
}
doomcom.remotenode = node;
doomcom.datalength = (short)c;