Patch b64decode padding error
parent
0eb4cd02d3
commit
cfdc5d5556
|
@ -134,6 +134,9 @@ def build_response_packet(taskingID, packetData, resultID=0):
|
||||||
|
|
||||||
if packetData:
|
if packetData:
|
||||||
packetData = base64.b64encode(packetData.decode('utf-8').encode('utf-8',errors='ignore'))
|
packetData = base64.b64encode(packetData.decode('utf-8').encode('utf-8',errors='ignore'))
|
||||||
|
if len(packetData) % 4:
|
||||||
|
packetData += '=' * (4 - len(packetData) % 4)
|
||||||
|
|
||||||
length = struct.pack('=L',len(packetData))
|
length = struct.pack('=L',len(packetData))
|
||||||
return packetType + totalPacket + packetNum + resultID + length + packetData
|
return packetType + totalPacket + packetNum + resultID + length + packetData
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -199,14 +199,7 @@ def parse_result_packet(packet, offset=0):
|
||||||
taskID = struct.unpack('=H', packet[6+offset:8+offset])[0]
|
taskID = struct.unpack('=H', packet[6+offset:8+offset])[0]
|
||||||
length = struct.unpack('=L', packet[8+offset:12+offset])[0]
|
length = struct.unpack('=L', packet[8+offset:12+offset])[0]
|
||||||
if length != '0':
|
if length != '0':
|
||||||
if length % 4:
|
|
||||||
#padding fix
|
|
||||||
datapart = packet[12+offset:12+offset+length]
|
|
||||||
datapart += '=' * (4 - length % 4)
|
|
||||||
data = base64.b64decode(datapart)
|
|
||||||
else:
|
|
||||||
data = base64.b64decode(packet[12+offset:12+offset+length])
|
data = base64.b64decode(packet[12+offset:12+offset+length])
|
||||||
#data = base64.b64decode(packet[12+offset:12+offset+length])
|
|
||||||
else:
|
else:
|
||||||
data = None
|
data = None
|
||||||
remainingData = packet[12+offset+length:]
|
remainingData = packet[12+offset+length:]
|
||||||
|
|
Loading…
Reference in New Issue