Changeset - 5002dce4a922
[Not reviewed]
0 1 0
moyamo - 10 years ago 2015-10-09 18:53:52
moyamodehacker@gmail.com
Prevent python plugin from crashing with InvalidWireType exception

Too much data was passed to wrapper.parseFromString resulting in it
trying to read another tag even after the WrapperMessage has ended
1 file changed with 1 insertions and 1 deletions:
0 comments (0 inline, 0 general)
plugin/python/NetworkPlugin.py
Show inline comments
 
@@ -310,25 +310,25 @@ class NetworkPlugin:
 
	def handleDataRead(self, data):
 
		self.m_data += data
 
		while len(self.m_data) != 0:
 
			expected_size = 0
 
			if (len(self.m_data) >= 4):
 
				expected_size = struct.unpack('!I', self.m_data[0:4])[0]
 
				if (len(self.m_data) - 4 < expected_size):
 
					return
 
			else:
 
				return
 

	
 
			wrapper = protocol_pb2.WrapperMessage()
 
			if (wrapper.ParseFromString(self.m_data[4:]) == False):
 
			if (wrapper.ParseFromString(self.m_data[4:expected_size+4]) == False):
 
				self.m_data = self.m_data[expected_size+4:]
 
				return
 

	
 
			self.m_data = self.m_data[4+expected_size:]
 

	
 
			if wrapper.type == protocol_pb2.WrapperMessage.TYPE_LOGIN:
 
					self.handleLoginPayload(wrapper.payload)
 
			elif wrapper.type == protocol_pb2.WrapperMessage.TYPE_LOGOUT:
 
					self.handleLogoutPayload(wrapper.payload)
 
			elif wrapper.type == protocol_pb2.WrapperMessage.TYPE_PING:
 
					self.sendPong()
 
			elif wrapper.type == protocol_pb2.WrapperMessage.TYPE_CONV_MESSAGE:
0 comments (0 inline, 0 general)