diff options
author | glx <glx@openttd.org> | 2008-07-21 15:50:55 +0000 |
---|---|---|
committer | glx <glx@openttd.org> | 2008-07-21 15:50:55 +0000 |
commit | 317868261a26f7303c2c8e0ffe801190319bf76a (patch) | |
tree | 8b754567996fda55333daaa790c92654cbe866ba /src | |
parent | e6aa4e1eb1f43f76e7fabfae7c4e9657113d78f8 (diff) | |
download | openttd-317868261a26f7303c2c8e0ffe801190319bf76a.tar.xz |
(svn r13775) -Codechange: enforce the validity of a NetworkAction (chat packet) issued by a client
Diffstat (limited to 'src')
-rw-r--r-- | src/network/network_server.cpp | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/network/network_server.cpp b/src/network/network_server.cpp index f85e15f29..1aca596d9 100644 --- a/src/network/network_server.cpp +++ b/src/network/network_server.cpp @@ -1166,7 +1166,21 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_CHAT) p->Recv_string(msg, MAX_TEXT_MSG_LEN); - NetworkServerSendChat(action, desttype, dest, msg, cs->index); + const NetworkClientInfo *ci = DEREF_CLIENT_INFO(cs); + switch (action) { + case NETWORK_ACTION_GIVE_MONEY: + if (!IsValidPlayerID(ci->client_playas)) break; + /* Fall-through */ + case NETWORK_ACTION_CHAT: + case NETWORK_ACTION_CHAT_CLIENT: + case NETWORK_ACTION_CHAT_COMPANY: + NetworkServerSendChat(action, desttype, dest, msg, cs->index); + break; + default: + IConsolePrintF(CC_ERROR, "WARNING: invalid chat action from client %d (IP: %s).", ci->client_index, GetPlayerIP(ci)); + SEND_COMMAND(PACKET_SERVER_ERROR)(cs, NETWORK_ERROR_NOT_EXPECTED); + break; + } } DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_SET_PASSWORD) |