wire: fix when the footer is too short

This commit is contained in:
Jan Pochyla 2016-11-15 18:09:45 +01:00
parent ecd8bd3b2a
commit e556aea42b
1 changed files with 4 additions and 1 deletions

View File

@ -115,7 +115,10 @@ Pass report payloads as `memoryview` for cheaper slicing.
msg_footer = data_tail[:_MSG_FOOTER_LEN] msg_footer = data_tail[:_MSG_FOOTER_LEN]
if len(msg_footer) < _MSG_FOOTER_LEN: if len(msg_footer) < _MSG_FOOTER_LEN:
data_tail = yield # read report with the rest of checksum data_tail = yield # read report with the rest of checksum
msg_footer += data_tail[:_MSG_FOOTER_LEN - len(msg_footer)] footer_tail = data_tail[:_MSG_FOOTER_LEN - len(msg_footer)]
if isinstance(msg_footer, memoryview):
msg_footer = bytearray(msg_footer)
msg_footer.extend(footer_tail)
data_checksum, = parse_message_footer(msg_footer) data_checksum, = parse_message_footer(msg_footer)
if data_checksum != checksum: if data_checksum != checksum: