diff options
author | rubidium <rubidium@openttd.org> | 2008-06-08 08:44:19 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2008-06-08 08:44:19 +0000 |
commit | d083afea90f1eb470dbc01e268d2d9a09238d5d2 (patch) | |
tree | 3a6d2c6974b7618289324e947bc94486ed1e6355 /src | |
parent | 04e31cae5aae0372f6a7bb6b7d9fc7b069eee4b2 (diff) | |
download | openttd-d083afea90f1eb470dbc01e268d2d9a09238d5d2.tar.xz |
(svn r13408) -Codechange: some stricter checking.
Diffstat (limited to 'src')
-rw-r--r-- | src/network/network_server.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/network/network_server.cpp b/src/network/network_server.cpp index b0f3a98c8..6cbfe21ba 100644 --- a/src/network/network_server.cpp +++ b/src/network/network_server.cpp @@ -611,6 +611,12 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_COMPANY_INFO) DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_NEWGRFS_CHECKED) { + if (cs->status != STATUS_INACTIVE) { + /* Illegal call, return error and ignore the packet */ + SEND_COMMAND(PACKET_SERVER_ERROR)(cs, NETWORK_ERROR_NOT_EXPECTED); + return; + } + NetworkClientInfo *ci = DEREF_CLIENT_INFO(cs); /* We now want a password from the client else we do not allow him in! */ @@ -627,6 +633,12 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_NEWGRFS_CHECKED) DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_JOIN) { + if (cs->status != STATUS_INACTIVE) { + /* Illegal call, return error and ignore the packet */ + SEND_COMMAND(PACKET_SERVER_ERROR)(cs, NETWORK_ERROR_NOT_EXPECTED); + return; + } + char name[NETWORK_CLIENT_NAME_LENGTH]; char unique_id[NETWORK_UNIQUE_ID_LENGTH]; NetworkClientInfo *ci; @@ -1011,6 +1023,12 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_QUIT) DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_ACK) { + if (cs->status < STATUS_AUTH) { + /* Illegal call, return error and ignore the packet */ + SEND_COMMAND(PACKET_SERVER_ERROR)(cs, NETWORK_ERROR_NOT_AUTHORIZED); + return; + } + uint32 frame = p->Recv_uint32(); /* The client is trying to catch up with the server */ @@ -1139,6 +1157,12 @@ void NetworkServerSendChat(NetworkAction action, DestType desttype, int dest, co DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_CHAT) { + if (cs->status < STATUS_AUTH) { + /* Illegal call, return error and ignore the packet */ + SEND_COMMAND(PACKET_SERVER_ERROR)(cs, NETWORK_ERROR_NOT_AUTHORIZED); + return; + } + NetworkAction action = (NetworkAction)p->Recv_uint8(); DestType desttype = (DestType)p->Recv_uint8(); int dest = p->Recv_uint16(); @@ -1151,6 +1175,12 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_CHAT) DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_SET_PASSWORD) { + if (cs->status != STATUS_ACTIVE) { + /* Illegal call, return error and ignore the packet */ + SEND_COMMAND(PACKET_SERVER_ERROR)(cs, NETWORK_ERROR_NOT_EXPECTED); + return; + } + char password[NETWORK_PASSWORD_LENGTH]; const NetworkClientInfo *ci; @@ -1164,6 +1194,12 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_SET_PASSWORD) DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_SET_NAME) { + if (cs->status != STATUS_ACTIVE) { + /* Illegal call, return error and ignore the packet */ + SEND_COMMAND(PACKET_SERVER_ERROR)(cs, NETWORK_ERROR_NOT_EXPECTED); + return; + } + char client_name[NETWORK_CLIENT_NAME_LENGTH]; NetworkClientInfo *ci; |