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

Use image loader when loading corrupted resources #3

Merged
merged 1 commit into from
Aug 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/fileformat/file_format/pe/pe_format.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1650,7 +1650,7 @@ void PeFormat::loadResourceNodes(std::vector<const PeLib::ResourceChild*> &nodes
continue;
}
auto resource = std::make_unique<Resource>();
resource->setOffset(leaf->getOffsetToData() - rva + formatParser->getResourceDirectoryOffset());
resource->setOffset(getImageLoader().getValidOffsetFromRva(leaf->getOffsetToData()));
resource->setSizeInFile(leaf->getSize());
resource->load(this);
resourceTable->addResource(std::move(resource));
Comment on lines 1652 to 1656

Choose a reason for hiding this comment

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

The code does not handle potential exceptions that might be thrown by getValidOffsetFromRva, getSize, or load methods. If any of these methods throw an exception, it could lead to resource leaks or inconsistent state.

Recommended Solution:
Wrap the code in a try-catch block to handle potential exceptions and ensure that resources are properly managed in case of an error.

Expand Down
Loading