Ver Fonte

* adjusted socket_max_client_packet to a more accurate (if guessed) value to prevent undefined client behavior (may only affect more recent clients?)
+ added a workaround for too large ZC_SKILLINFO_LIST packets resulting from all_skill group permission by sending excess skills one by one (bugreport:5348 and bugreport:5349)

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@15609 54d463be-8e91-2dee-dedb-b68131a5f0ec

lordttseven há 13 anos atrás
pai
commit
930048790b
4 ficheiros alterados com 21 adições e 4 exclusões
  1. 4 3
      conf/packet_athena.conf
  2. 2 1
      src/common/socket.c
  3. 1 0
      src/common/socket.h
  4. 14 0
      src/map/clif.c

+ 4 - 3
conf/packet_athena.conf

@@ -8,12 +8,13 @@ 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: 8192).
 // 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
+//       larger packets. The client will crash, when it receives larger packets,
+//       or worse, show undefined behavior.
+socket_max_client_packet: 8192
 
 //----- IP Rules Settings -----
 

+ 2 - 1
src/common/socket.c

@@ -219,7 +219,8 @@ 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.
-static size_t socket_max_client_packet = 24576;
+// TODO: This value is based on pure observation with newer clients. Replace with the actual buffer size if we ever get our hands on it.
+static size_t socket_max_client_packet = 8192;
 
 // initial recv buffer size (this will also be the max. size)
 // biggest known packet: S 0153 <len>.w <emblem data>.?B -> 24x24 256 color .bmp (0153 + len.w + 1618/1654/1756 bytes)

+ 1 - 0
src/common/socket.h

@@ -94,6 +94,7 @@ struct socket_data
 	void* session_data; // stores application-specific data related to the session
 };
 
+static size_t socket_max_client_packet;
 
 // Data prototype declaration
 

+ 14 - 0
src/map/clif.c

@@ -4534,6 +4534,10 @@ void clif_skillinfoblock(struct map_session_data *sd)
 	{
 		if( (id = sd->status.skill[i].id) != 0 )
 		{
+			// workaround for bugreport:5348
+			if (len + 37 > socket_max_client_packet)
+				break;
+
 			WFIFOW(fd,len)   = id;
 			WFIFOL(fd,len+2) = skill_get_inf(id);
 			WFIFOW(fd,len+6) = sd->status.skill[i].lv;
@@ -4549,6 +4553,16 @@ void clif_skillinfoblock(struct map_session_data *sd)
 	}
 	WFIFOW(fd,2)=len;
 	WFIFOSET(fd,len);
+
+	// workaround for bugreport:5348; send the remaining skills one by one to bypass packet size limit
+	for ( ; i < MAX_SKILL; i++)
+	{
+		if( (id = sd->status.skill[i].id) != 0 )
+		{
+			clif_addskill(sd, id);
+			clif_skillinfo(sd, id, 0); 
+		}
+	}
 }
 /**
  * Server tells client 'sd' to add skill of id 'id' to it's skill tree (e.g. with Ice Falcion item)