mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-16 00:12:51 +00:00
(svn r25589) -Fix [FS#5646]: Ensure that sent and received length of json strings are the same (based on patch by Xaroth)
This commit is contained in:
parent
7686587f02
commit
2e390613a6
@ -48,7 +48,7 @@ static const uint NETWORK_PASSWORD_LENGTH = 33; ///< The maximum lengt
|
|||||||
static const uint NETWORK_CLIENTS_LENGTH = 200; ///< The maximum length for the list of clients that controls a company, in bytes including '\0'
|
static const uint NETWORK_CLIENTS_LENGTH = 200; ///< The maximum length for the list of clients that controls a company, in bytes including '\0'
|
||||||
static const uint NETWORK_CLIENT_NAME_LENGTH = 25; ///< The maximum length of a client's name, in bytes including '\0'
|
static const uint NETWORK_CLIENT_NAME_LENGTH = 25; ///< The maximum length of a client's name, in bytes including '\0'
|
||||||
static const uint NETWORK_RCONCOMMAND_LENGTH = 500; ///< The maximum length of a rconsole command, in bytes including '\0'
|
static const uint NETWORK_RCONCOMMAND_LENGTH = 500; ///< The maximum length of a rconsole command, in bytes including '\0'
|
||||||
static const uint NETWORK_GAMESCRIPT_JSON_LENGTH = 1450; ///< The maximum length of a gamescript json string, in bytes including '\0'
|
static const uint NETWORK_GAMESCRIPT_JSON_LENGTH = SEND_MTU - 3; ///< The maximum length of a gamescript json string, in bytes including '\0'. Must not be longer than SEND_MTU including header (3 bytes)
|
||||||
static const uint NETWORK_CHAT_LENGTH = 900; ///< The maximum length of a chat message, in bytes including '\0'
|
static const uint NETWORK_CHAT_LENGTH = 900; ///< The maximum length of a chat message, in bytes including '\0'
|
||||||
|
|
||||||
static const uint NETWORK_GRF_NAME_LENGTH = 80; ///< Maximum length of the name of a GRF
|
static const uint NETWORK_GRF_NAME_LENGTH = 80; ///< Maximum length of the name of a GRF
|
||||||
|
@ -579,10 +579,10 @@ NetworkRecvStatus ServerNetworkAdminSocketHandler::SendConsole(const char *origi
|
|||||||
*/
|
*/
|
||||||
NetworkRecvStatus ServerNetworkAdminSocketHandler::SendGameScript(const char *json)
|
NetworkRecvStatus ServerNetworkAdminSocketHandler::SendGameScript(const char *json)
|
||||||
{
|
{
|
||||||
/* At the moment we cannot transmit anything larger than MTU. So the string
|
/* At the moment we cannot transmit anything larger than MTU. So we limit
|
||||||
* has to be no longer than the length of the json + '\0' + 3 bytes of the
|
* the maximum amount of json data that can be sent. Account also for
|
||||||
* packet header. */
|
* the trailing \0 of the string */
|
||||||
if (strlen(json) + 1 + 3 >= SEND_MTU) return NETWORK_RECV_STATUS_OKAY;
|
if (strlen(json) + 1 >= NETWORK_GAMESCRIPT_JSON_LENGTH) return NETWORK_RECV_STATUS_OKAY;
|
||||||
|
|
||||||
Packet *p = new Packet(ADMIN_PACKET_SERVER_GAMESCRIPT);
|
Packet *p = new Packet(ADMIN_PACKET_SERVER_GAMESCRIPT);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user