Skip to content

Commit

Permalink
PE: Test the existence of DIRECTORY_ENTRY_DEBUG before accessing. (#512)
Browse files Browse the repository at this point in the history
  • Loading branch information
ltfish authored Sep 25, 2024
1 parent 3dbb5b1 commit 0668bf2
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions cle/backends/pe/pe.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,10 +358,11 @@ def _find_pdb_path(self):
checks = []

# Check PE file for path to PDB
for de in self._pe.DIRECTORY_ENTRY_DEBUG:
if de.entry and hasattr(de.entry, "PdbFileName"):
path = de.entry.PdbFileName.rstrip(b"\x00").decode()
break
if hasattr(self._pe, "DIRECTORY_ENTRY_DEBUG"):
for de in self._pe.DIRECTORY_ENTRY_DEBUG:
if de.entry and hasattr(de.entry, "PdbFileName"):
path = de.entry.PdbFileName.rstrip(b"\x00").decode()
break

if path:
if os.path.exists(path):
Expand Down

0 comments on commit 0668bf2

Please sign in to comment.