From: havoc Date: Thu, 23 Feb 2006 16:19:09 +0000 (+0000) Subject: fix rcon_password validation to refuse whitespace, and refuse empty passwords (as... X-Git-Tag: xonotic-v0.1.0preview~4294 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=8fafb1561a8a7eeb956679704a64335914447bc0;p=xonotic%2Fdarkplaces.git fix rcon_password validation to refuse whitespace, and refuse empty passwords (as it was meant to do all along, but wasn't working properly) git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@6019 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/host_cmd.c b/host_cmd.c index 2c5d185f..98b7d090 100644 --- a/host_cmd.c +++ b/host_cmd.c @@ -1972,15 +1972,25 @@ Host_Rcon_f */ void Host_Rcon_f (void) // credit: taken from QuakeWorld { + int i; lhnetaddress_t to; lhnetsocket_t *mysocket; - if (!rcon_password.string) + if (!rcon_password.string || !rcon_password.string[0]) { Con_Printf ("You must set rcon_password before issuing an rcon command.\n"); return; } + for (i = 0;rcon_password.string[i];i++) + { + if (rcon_password.string[i] <= ' ') + { + Con_Printf("rcon_password is not allowed to have any whitespace.\n"); + return; + } + } + if (cls.netcon) to = cls.netcon->peeraddress; else diff --git a/netconn.c b/netconn.c index 74ba01ba..9628a380 100755 --- a/netconn.c +++ b/netconn.c @@ -1574,7 +1574,7 @@ static int NetConn_ServerParsePacket(lhnetsocket_t *mysocket, unsigned char *dat if (i < (int)sizeof(password) - 1) password[i++] = *s; password[i] = 0; - if (!strcmp(rcon_password.string, password)) + 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);