Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: PE object has no attribute DIRECTORY_ENTRY_BASERELOC #332

Closed
pd-fkie opened this issue Aug 31, 2021 · 0 comments
Closed

Bug: PE object has no attribute DIRECTORY_ENTRY_BASERELOC #332

pd-fkie opened this issue Aug 31, 2021 · 0 comments
Assignees
Labels

Comments

@pd-fkie
Copy link

pd-fkie commented Aug 31, 2021

PE.relocate_image invokes parse_data_directories if the object doesn't have
the attribute DIRECTORY_ENTRY_BASERELOC yet.
However a verification that parse_data_directories actually created
self.DIRECTORY_ENTRY_BASERELOC is missing and the function directly uses
DIRECTORY_ENTRY_BASERELOC resulting in the exception:

AttributeError: 'PE' object has no attribute 'DIRECTORY_ENTRY_BASERELOC'
Traceback (most recent call last):
  File "fuzz_pefile.py", line 22, in TestOneInput
    p.relocate_image(0x40000)
  File "pefile.py", line 5524, in relocate_image
    for reloc in self.DIRECTORY_ENTRY_BASERELOC:

Other functions that use parse_data_directories are not missing this check.


Crash file: crash-8ffa487ba8fe2bc6f6af1e9ba464aea5aba58374

erocarrera added a commit that referenced this issue Aug 31, 2021
Pefile attempts to parse the `DIRECTORY_ENTRY_BASERELOC` if it has not been parsed yet, but it may not exist or be unparseable. Check for that case, log a warning, and don't crash.
@erocarrera erocarrera self-assigned this Aug 31, 2021
@erocarrera erocarrera added the bug label Aug 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants