summaryrefslogtreecommitdiff
blob: dc97ffcf4a7c622229d338c6d2459ef14a7a8a3b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
The size needs to be at least 2 or the code gets hung up.

http://bugs.gentoo.org/98922

--- src/NetPanzer/Network/ServerSocket.cpp
+++ src/NetPanzer/Network/ServerSocket.cpp
@@ -169,7 +169,7 @@
 
             size = htol16(*((int16_t*) tempbuffer));
 
-            if ( (size < 0) || (size > _MAX_NET_PACKET_SIZE) ) {
+            if ( (size < 2) || (size > _MAX_NET_PACKET_SIZE) ) {
                 LOG( ("OnReadStreamServer : Invalid Packet Size %d", size) );
                 recvoffset = 0;
                 client->headerincomplete = false;
@@ -224,7 +224,7 @@
 
                 size = htol16(*((int16_t*) tempbuffer));
 
-                if ( (size < 0) || (size > _MAX_NET_PACKET_SIZE) ) {
+                if ( (size < 2) || (size > _MAX_NET_PACKET_SIZE) ) {
                     LOG( ("OnReadStreamServer : Invalid Packet Size %d", size) );
                     recvoffset = 0;
                     client->messageincomplete = false;
@@ -266,7 +266,7 @@
             } else if (recvsize >= 2) {
                 size = htol16(*((int16_t*) (recvbuffer + recvoffset)));
 
-                if( (size < 0) || (size > _MAX_NET_PACKET_SIZE) ) {
+                if( (size < 2) || (size > _MAX_NET_PACKET_SIZE) ) {
                     LOG( ("OnReadStreamServer : Invalid Packet Size %d", size) );
                     recvoffset = 0;
                     client->tempoffset = 0;