]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
NetConn_ReceivedMessage now verifies that the packet's internal length value matches...
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 23 May 2005 22:29:14 +0000 (22:29 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 23 May 2005 22:29:14 +0000 (22:29 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@5324 d7cf8633-e32d-0410-b094-e92efae38249

netconn.c

index 6f96f28ba0e1d0b9473dee7d4f436287eebef544..97ad13cc10bb9e1ddfc3126118df794f580c5404 100755 (executable)
--- a/netconn.c
+++ b/netconn.c
@@ -763,14 +763,15 @@ int NetConn_ReceivedMessage(netconn_t *conn, qbyte *data, int length)
        unsigned int count;
        unsigned int flags;
        unsigned int sequence;
+       int qlength;
 
-       length = BigLong(((int *)data)[0]);
-       flags = length & ~NETFLAG_LENGTH_MASK;
-       length &= NETFLAG_LENGTH_MASK;
-    if (length >= 8)
+       if (length >= 8)
        {
+               qlength = (unsigned int)BigLong(((int *)data)[0]);
+               flags = qlength & ~NETFLAG_LENGTH_MASK;
+               qlength &= NETFLAG_LENGTH_MASK;
                // control packets were already handled
-               if (!(flags & NETFLAG_CTL))
+               if (!(flags & NETFLAG_CTL) && qlength == length)
                {
                        sequence = BigLong(((int *)data)[1]);
                        packetsReceived++;
@@ -852,7 +853,7 @@ int NetConn_ReceivedMessage(netconn_t *conn, qbyte *data, int length)
                                                                        "Dropping the message!\n", sequence );
                                                conn->receiveMessageLength = 0;
                                                return 1;
-                                       } 
+                                       }
                                        if (flags & NETFLAG_EOM)
                                        {
                                                reliableMessagesReceived++;