]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
allow multiple rcon commands in the same packet, separated by NUL
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Tue, 10 Jul 2007 10:04:42 +0000 (10:04 +0000)
committerdivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Tue, 10 Jul 2007 10:04:42 +0000 (10:04 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@7481 d7cf8633-e32d-0410-b094-e92efae38249

netconn.c

index f8be676e2a11609125808ad8f651abb787722104..b231c11ad98b5a8d2b772f6655abd4a87f2879c6 100755 (executable)
--- a/netconn.c
+++ b/netconn.c
@@ -2091,6 +2091,7 @@ static int NetConn_ServerParsePacket(lhnetsocket_t *mysocket, unsigned char *dat
                {
                        int i;
                        char *s = string + 5;
+                       char *endpos = string + length + 1; // one behind the NUL, so adding strlen+1 will eventually reach it
                        char password[64];
                        for (i = 0;*s > ' ';s++)
                                if (i < (int)sizeof(password) - 1)
@@ -2099,10 +2100,23 @@ static int NetConn_ServerParsePacket(lhnetsocket_t *mysocket, unsigned char *dat
                        if (password[0] > ' ' && !strcmp(rcon_password.string, password))
                        {
                                // looks like a legitimate rcon command with the correct password
-                               Con_Printf("server received rcon command from %s:\n%s\n", host_client ? host_client->name : addressstring2, s);
+                               char *s_ptr = s;
+                               while(s_ptr != endpos)
+                               {
+                                       size_t l = strlen(s_ptr);
+                                       if(l)
+                                               Con_Printf("server received rcon command from %s:\n%s\n", host_client ? host_client->name : addressstring2, s_ptr);
+                                       s_ptr += l + 1;
+                               }
                                rcon_redirect = true;
                                rcon_redirect_bufferpos = 0;
-                               Cmd_ExecuteString(s, src_command);
+                               while(s != endpos)
+                               {
+                                       size_t l = strlen(s);
+                                       if(l)
+                                               Cmd_ExecuteString(s, src_command);
+                                       s += l + 1;
+                               }
                                rcon_redirect_buffer[rcon_redirect_bufferpos] = 0;
                                rcon_redirect = false;
                                // print resulting text to client