Skip to content

Commit

Permalink
Non-functional change in parse_rich_header
Browse files Browse the repository at this point in the history
Change rich header check to be more logical in checking the DanS bytes; functionally equivalent.
  • Loading branch information
j-t-1 authored Dec 5, 2024
1 parent 4b3b1e2 commit f102647
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions pefile.py
Original file line number Diff line number Diff line change
Expand Up @@ -3373,7 +3373,6 @@ def parse_rich_header(self):
"""

# Rich Header constants
#
DANS = 0x536E6144 # 'DanS' as dword
RICH = 0x68636952 # 'Rich' as dword

Expand Down Expand Up @@ -3417,7 +3416,7 @@ def parse_rich_header(self):
checksum = int.from_bytes(key, "little")
# the checksum should be present 3 times after the DanS signature
if (
data[0] ^ checksum != DANS
data[0] != DANS ^ checksum
or data[1] != checksum
or data[2] != checksum
or data[3] != checksum
Expand All @@ -3433,16 +3432,13 @@ def parse_rich_header(self):
data = data[4:]
for i in range(len(data) // 2):
# Stop until the Rich footer signature is found
#
if data[2 * i] == RICH:
# it should be followed by the checksum
#
if data[2 * i + 1] != checksum:
self.__warnings.append("Rich Header is malformed")
break

# header values come by pairs
#
headervalues += [data[2 * i] ^ checksum, data[2 * i + 1] ^ checksum]
return result

Expand Down

0 comments on commit f102647

Please sign in to comment.