[enet-cvs] CVS: enet protocol.c,1.13,1.14
Lee Salzman
enet-discuss@lists.puremagic.com
Mon, 21 Apr 2003 12:36:17 -0600
Update of /home/enet/cvsroot/enet
In directory sferik:/tmp/cvs-serv23462
Modified Files:
protocol.c
Log Message:
Sanity checking against malicious packets specifying bogus channels
Index: protocol.c
===================================================================
RCS file: /home/enet/cvsroot/enet/protocol.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- protocol.c 2003/03/12 00:50:59 1.13
+++ protocol.c 2003/04/21 18:36:14 1.14
@@ -231,7 +231,8 @@
{
ENetPacket * packet;
- if (command -> header.commandLength <= sizeof (ENetProtocolSendReliable))
+ if (command -> header.commandLength <= sizeof (ENetProtocolSendReliable) ||
+ command -> header.channelID >= peer -> channelCount)
return;
packet = enet_packet_create ((const enet_uint8 *) command + sizeof (ENetProtocolSendReliable),
@@ -246,7 +247,8 @@
{
ENetPacket * packet;
- if (command -> header.commandLength <= sizeof (ENetProtocolSendUnreliable))
+ if (command -> header.commandLength <= sizeof (ENetProtocolSendUnreliable) ||
+ command -> header.channelID >= peer -> channelCount)
return;
packet = enet_packet_create ((const enet_uint8 *) command + sizeof (ENetProtocolSendUnreliable),
@@ -269,7 +271,8 @@
ENetListIterator currentCommand;
ENetIncomingCommand * startCommand;
- if (command -> header.commandLength <= sizeof (ENetProtocolSendFragment))
+ if (command -> header.commandLength <= sizeof (ENetProtocolSendFragment) ||
+ command -> header.channelID >= peer -> channelCount)
return;
startSequenceNumber = ENET_NET_TO_HOST_32 (command -> sendFragment.startSequenceNumber);