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

Fixed high memory usage in debug directory (#824) #825

Merged
merged 1 commit into from
Jul 26, 2020
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
5 changes: 3 additions & 2 deletions src/pelib/DebugDirectory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace PeLib
std::size_t rva = imageLoader.getDataDirRva(PELIB_IMAGE_DIRECTORY_ENTRY_DEBUG);
std::size_t size = imageLoader.getDataDirSize(PELIB_IMAGE_DIRECTORY_ENTRY_DEBUG);
std::size_t sizeOfImage = imageLoader.getSizeOfImage();
if ((rva + size) > sizeOfImage)
if ((rva + size) < rva || (rva + size) > sizeOfImage)
{
return ERROR_INVALID_FILE;
}
Expand All @@ -38,7 +38,8 @@ namespace PeLib
// For each debug directory, also read its data
for(auto & debugEntry : debugInfo)
{
if ((debugEntry.idd.PointerToRawData >= ulFileSize) ||
if ((debugEntry.idd.PointerToRawData + debugEntry.idd.SizeOfData) < debugEntry.idd.PointerToRawData ||
(debugEntry.idd.PointerToRawData >= ulFileSize) ||
(debugEntry.idd.PointerToRawData + debugEntry.idd.SizeOfData >= ulFileSize))
{
return ERROR_INVALID_FILE;
Expand Down