diff options
author | Darkvater <darkvater@openttd.org> | 2005-12-20 20:52:05 +0000 |
---|---|---|
committer | Darkvater <darkvater@openttd.org> | 2005-12-20 20:52:05 +0000 |
commit | 0f41b99c5e106e11708d0be478e7defb92f0a43a (patch) | |
tree | a8811c0d9f666534f8861378b0eb8b6629c5186b /network_udp.c | |
parent | 8f873d4ece827d8f95f8ded0f49b47dbe5942506 (diff) | |
download | openttd-0f41b99c5e106e11708d0be478e7defb92f0a43a.tar.xz |
(svn r3322) - Fix: Network window crash when it receives invalid information for example from the integrated nightly, so validate the network-input when it is received
- CodeChange: added str_validate(char *str) function that checks if a string contains only printable characters and if not, replaces those characters by question marks. Also move IsValidAsciiChar() to string.h
Diffstat (limited to 'network_udp.c')
-rw-r--r-- | network_udp.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/network_udp.c b/network_udp.c index a24e8da7d..28e5a0301 100644 --- a/network_udp.c +++ b/network_udp.c @@ -119,6 +119,12 @@ DEF_UDP_RECEIVE_COMMAND(PACKET_UDP_SERVER_RESPONSE) item->info.map_set = NetworkRecv_uint8(&_udp_cs, p); item->info.dedicated = NetworkRecv_uint8(&_udp_cs, p); + str_validate(item->info.server_name); + str_validate(item->info.server_revision); + str_validate(item->info.map_name); + if (item->info.server_lang >= NETWORK_NUM_LANGUAGES) item->info.server_lang = 0; + if (item->info.map_set >= NUM_LANDSCAPE ) item->info.map_set = 0; + if (item->info.hostname[0] == '\0') snprintf(item->info.hostname, sizeof(item->info.hostname), "%s", inet_ntoa(client_addr->sin_addr)); } |