summaryrefslogtreecommitdiff
path: root/src/network/network_admin.cpp
diff options
context:
space:
mode:
authorplanetmaker <planetmaker@openttd.org>2013-07-12 17:11:16 +0000
committerplanetmaker <planetmaker@openttd.org>2013-07-12 17:11:16 +0000
commit2e390613a6c5854b62215ada489ef0c792a6507f (patch)
tree064e65ab70328914f86b1c99a5d71c9d6e33dd14 /src/network/network_admin.cpp
parent7686587f02ff76bb7d6f899b989701adeda5b6e4 (diff)
downloadopenttd-2e390613a6c5854b62215ada489ef0c792a6507f.tar.xz
(svn r25589) -Fix [FS#5646]: Ensure that sent and received length of json strings are the same (based on patch by Xaroth)
Diffstat (limited to 'src/network/network_admin.cpp')
-rw-r--r--src/network/network_admin.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/network/network_admin.cpp b/src/network/network_admin.cpp
index 326559e0b..0c060b755 100644
--- a/src/network/network_admin.cpp
+++ b/src/network/network_admin.cpp
@@ -579,10 +579,10 @@ NetworkRecvStatus ServerNetworkAdminSocketHandler::SendConsole(const char *origi
*/
NetworkRecvStatus ServerNetworkAdminSocketHandler::SendGameScript(const char *json)
{
- /* At the moment we cannot transmit anything larger than MTU. So the string
- * has to be no longer than the length of the json + '\0' + 3 bytes of the
- * packet header. */
- if (strlen(json) + 1 + 3 >= SEND_MTU) return NETWORK_RECV_STATUS_OKAY;
+ /* At the moment we cannot transmit anything larger than MTU. So we limit
+ * the maximum amount of json data that can be sent. Account also for
+ * the trailing \0 of the string */
+ if (strlen(json) + 1 >= NETWORK_GAMESCRIPT_JSON_LENGTH) return NETWORK_RECV_STATUS_OKAY;
Packet *p = new Packet(ADMIN_PACKET_SERVER_GAMESCRIPT);