From f4b42b26fb3c4b142b46c97e037fb16bc1e07ea6 Mon Sep 17 00:00:00 2001 From: Lemongrass3110 Date: Tue, 8 Dec 2015 17:35:58 +0100 Subject: [PATCH] Updated the maximum size for packets According to 3ceam revision 764 clients from 2013-12-23 on can deal with bigger packets. 3ceam uses 65636 as maximum, but we decided to stick with the maximum for unsigned shorts. Thanks to Rytech! Please consider staying with the default value, because we will remove this configuration soon and make it a source side define which is depending on the packetversion define. --- conf/packet_athena.conf | 6 ++++-- src/common/socket.c | 20 +++++++++++++++++++- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/conf/packet_athena.conf b/conf/packet_athena.conf index 0741ac013c..2cd916adb3 100644 --- a/conf/packet_athena.conf +++ b/conf/packet_athena.conf @@ -8,12 +8,14 @@ debug: no // How long can a socket stall before closing the connection (in seconds) stall_time: 60 -// Maximum allowed size for clients packets in bytes (default: 24576). +// Maximum allowed size for clients packets in bytes (default: 65535). // NOTE: To reduce the size of reported packets, lower the values of defines, which // have been customized, such as MAX_STORAGE, MAX_GUILD_STORAGE or MAX_CART. // NOTE: Do not modify this setting, unless the client has been modified to support // larger packets. The client will crash, when it receives larger packets. -socket_max_client_packet: 24576 +socket_max_client_packet: 65535 +// For clients before 2013-12-23 uncomment this +//socket_max_client_packet: 24576 //----- IP Rules Settings ----- diff --git a/src/common/socket.c b/src/common/socket.c index c936493561..07707b702b 100644 --- a/src/common/socket.c +++ b/src/common/socket.c @@ -212,7 +212,11 @@ int naddr_ = 0; // # of ip addresses // Maximum packet size in bytes, which the client is able to handle. // Larger packets cause a buffer overflow and stack corruption. +#if PACKETVER < 20131223 static size_t socket_max_client_packet = 24576; +#else +static size_t socket_max_client_packet = USHRT_MAX; +#endif #ifdef SHOW_SERVER_STATS // Data I/O statistics @@ -1171,8 +1175,22 @@ int socket_config_read(const char* cfgName) ddos_autoreset = atoi(w2); else if (!strcmpi(w1,"debug")) access_debug = config_switch(w2); - else if (!strcmpi(w1,"socket_max_client_packet")) + else if (!strcmpi(w1,"socket_max_client_packet")){ socket_max_client_packet = strtoul(w2, NULL, 0); + +#if PACKETVER < 20131223 + if( socket_max_client_packet > 24576 ){ + ShowWarning( "socket_max_client_packet: Value %u is to high. Defaulting to %u.\n", socket_max_client_packet, 24576 ); + ShowWarning( "socket_max_client_packet: If you want to use this value consider upgrading your client to 2013-12-23 or newer.\n" ); + socket_max_client_packet = 24576; + } +#else + if( socket_max_client_packet > USHRT_MAX ){ + ShowWarning( "socket_max_client_packet: Value %u is to high. Defaulting to %u.\n", socket_max_client_packet, USHRT_MAX ); + socket_max_client_packet = USHRT_MAX; + } +#endif + } #endif else if (!strcmpi(w1, "import")) socket_config_read(w2);