summaryrefslogtreecommitdiff
path: root/network.c
diff options
context:
space:
mode:
authortruelight <truelight@openttd.org>2005-01-05 14:39:48 +0000
committertruelight <truelight@openttd.org>2005-01-05 14:39:48 +0000
commit523a6a1cffd1a7567453835500f387f3499b10a2 (patch)
tree0321af6b507ef39cda02042c21cc3ae5e417a162 /network.c
parentf1e9fdf76d951dec71c330f12783917cae464160 (diff)
downloadopenttd-523a6a1cffd1a7567453835500f387f3499b10a2.tar.xz
(svn r1389) -Add: [Network] Added packet protection. No longer a client or server
reads beyond the size of the packet -Fix: [Network] A server no longer crashes when a client sends an invalid DoCommand, but drops the client instead.
Diffstat (limited to 'network.c')
-rw-r--r--network.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/network.c b/network.c
index 31b3b09aa..26fd3b1ce 100644
--- a/network.c
+++ b/network.c
@@ -482,7 +482,10 @@ void NetworkCloseClient(NetworkClientState *cs)
{
NetworkClientInfo *ci;
// Socket is already dead
- if (cs->socket == INVALID_SOCKET) return;
+ if (cs->socket == INVALID_SOCKET) {
+ cs->quited = true;
+ return;
+ }
DEBUG(net, 1) ("[NET] Closed client connection");
@@ -509,6 +512,7 @@ void NetworkCloseClient(NetworkClientState *cs)
closesocket(cs->socket);
cs->writable = false;
+ cs->quited = true;
// Free all pending and partially received packets
while (cs->packet_queue != NULL) {