From: divverent Date: Tue, 10 Jul 2007 10:04:42 +0000 (+0000) Subject: allow multiple rcon commands in the same packet, separated by NUL X-Git-Tag: xonotic-v0.1.0preview~2984 X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fdarkplaces.git;a=commitdiff_plain;h=76c442dcbc2030cf8095594d51012c0885d4391a allow multiple rcon commands in the same packet, separated by NUL git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@7481 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/netconn.c b/netconn.c index f8be676e..b231c11a 100755 --- 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