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

fix: Iterate all debug directory entries #740

Merged
merged 1 commit into from Aug 1, 2022
Merged

Conversation

Swatinem
Copy link
Member

Turns out a PE file can have more than one debug directory entry.
We now iterate over all of them, trying to find the one that has a valid
CodeView record that we can use to get a debug_id from.

Crashpad does the same here, for reference:
https://chromium.googlesource.com/crashpad/crashpad/+/refs/heads/main/snapshot/win/pe_image_reader.cc#162

Turns out a PE file can have more than one debug directory entry.
We now iterate over all of them, trying to find the one that has a valid
CodeView record that we can use to get a debug_id from.
if (!debug_dict || debug_dict->Type != IMAGE_DEBUG_TYPE_CODEVIEW) {
size_t table_size = (size_t)debug_entry.Size;
size_t entry_size = sizeof(IMAGE_DEBUG_DIRECTORY);
if (table_size % entry_size != 0) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be possible to somehow iterate over some entries and just drop the one that was somehow malformed and has fewer bytes than necessary? Or is it not possible to tell which one would even be broken at this point?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think doing the same thing as crashpad here is okay. These structs have a fixed size, and the table should always be a multiple of that, otherwise the compiler did something wrong

@Swatinem Swatinem merged commit 4890a30 into master Aug 1, 2022
@Swatinem Swatinem deleted the fix/debug-directory branch August 1, 2022 10:59
supervacuus added a commit that referenced this pull request Aug 1, 2022
supervacuus added a commit that referenced this pull request Aug 1, 2022
- bumps Linux CI host to Ubuntu 22.04
- bumps new gcc to 12, clang to 14
- bumps Android API/NDK to the latest versions (uses x86_64 images)
- renames CI jobs, so their names are version-independent (for easier updating)
- removes llvm apt repo
- replaces codechecker "manual" build with snap package
- update changelog with #740.

Co-authored-by: Mischan Toosarani-Hausberger <mischan@abovevacant.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants