Skip to content

Commit

Permalink
Fix for patches where the CRC32 happens to contain "PA"
Browse files Browse the repository at this point in the history
  • Loading branch information
m417z committed Sep 16, 2022
1 parent 75f463f commit 01e39fd
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions data/delta_patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,14 @@ def apply_patchfile_to_buffer(buf, buflen, patchpath, legacy):

# some patches (Windows Update MSU) come with a CRC32 prepended to the file
# if the file doesn't start with the signature (PA) then check it
if patch_contents[:2] != b"PA":
paoff = patch_contents.find(b"PA")
if paoff != 4:
# if patch_contents[:2] != b"PA":
# paoff = patch_contents.find(b"PA")
# if paoff != 4:

# Above is the original code, which breaks if the CRC32 happens to contain
# "PA". Just assume that the first 4 bytes are the CRC32.
if True:
if patch_contents[4:6] != b"PA":
raise Exception("Patch is invalid")
crc = int.from_bytes(patch_contents[:4], 'little')
patch_contents = patch_contents[4:]
Expand Down

0 comments on commit 01e39fd

Please sign in to comment.