summaryrefslogtreecommitdiff
path: root/src/network/network_client.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2009-01-07 15:27:19 +0000
committerrubidium <rubidium@openttd.org>2009-01-07 15:27:19 +0000
commit8d017f0ea1e21276d00f3325acd71e40c53cfc39 (patch)
tree26ecdc3e2c01b662df452e9e13bbf21461754bc2 /src/network/network_client.cpp
parentf5b23103d7f73f1b5e5828133f20e8914f7e2a3e (diff)
downloadopenttd-8d017f0ea1e21276d00f3325acd71e40c53cfc39.tar.xz
(svn r14897) -Codechange: don't allow a few command flags to be sent over the network as it's bogus information anyway; e.g. the "do not send over network" flag as it will be set whenever the command is received from the server/client.
-Codechange: test earlier whether the command (send from the server) is actually valid.
Diffstat (limited to 'src/network/network_client.cpp')
-rw-r--r--src/network/network_client.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/network/network_client.cpp b/src/network/network_client.cpp
index 2d7256beb..1c56fda7c 100644
--- a/src/network/network_client.cpp
+++ b/src/network/network_client.cpp
@@ -685,6 +685,24 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_COMMAND)
cp->my_cmd = p->Recv_bool();
cp->next = NULL;
+ if (!IsValidCommand(cp->cmd)) {
+ IConsolePrintF(CC_ERROR, "WARNING: invalid command from server, dropping...");
+ free(cp);
+ return NETWORK_RECV_STATUS_MALFORMED_PACKET;
+ }
+
+ if (GetCommandFlags(cp->cmd) & CMD_OFFLINE) {
+ IConsolePrintF(CC_ERROR, "WARNING: offline only command from server, dropping...");
+ free(cp);
+ return NETWORK_RECV_STATUS_MALFORMED_PACKET;
+ }
+
+ if ((cp->cmd & CMD_FLAGS_MASK) != 0) {
+ IConsolePrintF(CC_ERROR, "WARNING: invalid command flag from server, dropping...");
+ free(cp);
+ return NETWORK_RECV_STATUS_MALFORMED_PACKET;
+ }
+
// The server did send us this command..
// queue it in our own queue, so we can handle it in the upcoming frame!