summaryrefslogtreecommitdiff
path: root/src/network
diff options
context:
space:
mode:
authorglx <glx@openttd.org>2008-07-21 15:50:55 +0000
committerglx <glx@openttd.org>2008-07-21 15:50:55 +0000
commit11ca40cf88f0ab65584c01771f5c933d6b282aef (patch)
tree8b754567996fda55333daaa790c92654cbe866ba /src/network
parent97990fa9fe76601bf56e4010f3e8d599c2c929f8 (diff)
downloadopenttd-11ca40cf88f0ab65584c01771f5c933d6b282aef.tar.xz
(svn r13775) -Codechange: enforce the validity of a NetworkAction (chat packet) issued by a client
Diffstat (limited to 'src/network')
-rw-r--r--src/network/network_server.cpp16
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)