Merge pull request #9783 from bridadan/fix_unsigned_crc_header

Ensure header CRC is written as unsigned int
pull/9802/head
Cruz Monrreal 2019-02-21 11:23:23 -06:00 committed by GitHub
commit 091da53589
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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()