Skip to content

Commit

Permalink
Backport non UTF-8 file name bugfix from pyinstxtractor-ng
Browse files Browse the repository at this point in the history
  • Loading branch information
extremecoders-re authored Aug 20, 2023
1 parent 4c89bd5 commit 9565295
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pyinstxtractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,12 @@ def parseTOC(self):
'!IIIBc{0}s'.format(entrySize - nameLen), \
self.fPtr.read(entrySize - 4))

name = name.decode('utf-8').rstrip('\0')
try:
name = name.decode("utf-8").rstrip("\0")
except UnicodeDecodeError:
newName = str(uniquename())
print('[!] Warning: File name {0} contains invalid bytes. Using random name {1}'.format(name, newName))
name = newName

# Prevent writing outside the extraction directory
if name.startswith("/"):
Expand Down

0 comments on commit 9565295

Please sign in to comment.