Ensure header CRC is written as unsigned int

pull/9783/head
Brian Daniels 2019-02-20 17:34:05 -06:00
parent f61dee1626
commit 434d86b08a
1 changed files with 3 additions and 2 deletions

View File

@ -398,8 +398,9 @@ def _fill_header(region_list, current_region):
else:
ih = intelhex_offset(region_dict[data].filename, offset=region_dict[data].start)
if subtype.startswith("CRCITT32"):
fmt = {"CRCITT32be": ">l", "CRCITT32le": "<l"}[subtype]
header.puts(start, struct.pack(fmt, zlib.crc32(ih.tobinarray())))
fmt = {"CRCITT32be": ">L", "CRCITT32le": "<L"}[subtype]
crc_val = zlib.crc32(ih.tobinarray()) & 0xffffffff
header.puts(start, struct.pack(fmt, crc_val))
elif subtype.startswith("SHA"):
if subtype == "SHA256":
hash = hashlib.sha256()