(svn r21687) -Fix: verify the colour code we received from the server is valid

This commit is contained in:
smatz 2011-01-01 17:02:29 +00:00
parent 62bc55cf7b
commit 666fbb28c2
2 changed files with 10 additions and 3 deletions

View File

@ -30,4 +30,10 @@ enum ConsoleColour {
CC_WHITE = 12,
};
static inline bool IsValidConsoleColour(uint c)
{
return c == CC_DEFAULT || c == CC_ERROR || c == CC_WARNING || c == CC_INFO ||
c == CC_DEBUG || c == CC_COMMAND || c == CC_WHITE;
}
#endif /* CONSOLE_TYPE_H */

View File

@ -1067,12 +1067,13 @@ DEF_GAME_RECEIVE_COMMAND(Client, PACKET_SERVER_RCON)
{
if (this->status < STATUS_AUTHORIZED) return NETWORK_RECV_STATUS_MALFORMED_PACKET;
char rcon_out[NETWORK_RCONCOMMAND_LENGTH];
uint colour_code = p->Recv_uint16();
if (!IsValidConsoleColour(colour_code)) return NETWORK_RECV_STATUS_MALFORMED_PACKET;
ConsoleColour colour_code = (ConsoleColour)p->Recv_uint16();
char rcon_out[NETWORK_RCONCOMMAND_LENGTH];
p->Recv_string(rcon_out, sizeof(rcon_out));
IConsolePrint(colour_code, rcon_out);
IConsolePrint((ConsoleColour)colour_code, rcon_out);
return NETWORK_RECV_STATUS_OKAY;
}