mirror of
https://github.com/avast/retdec.git
synced 2024-11-23 21:10:13 +00:00
Fixed issue #911
This commit is contained in:
parent
ec5cd887e0
commit
28505dd910
@ -162,7 +162,7 @@ namespace PeLib
|
||||
const std::uint32_t PELIB_IMAGE_RESOURCE_DATA_IS_DIRECTORY = 0x80000000;
|
||||
const std::uint32_t PELIB_IMAGE_RESOURCE_NAME_IS_STRING = 0x80000000;
|
||||
const std::uint32_t PELIB_IMAGE_RESOURCE_RVA_MASK = 0x7FFFFFFF;
|
||||
const std::uint16_t PELIB_MAX_RESOURCE_ENTRIES = 0xC000; // Maximum number of resource directory entries we consider OK
|
||||
const std::uint16_t PELIB_MAX_RESOURCE_ENTRIES = 0x8000; // Maximum number of resource directory entries we consider OK
|
||||
|
||||
enum : std::uint32_t
|
||||
{
|
||||
|
@ -318,9 +318,7 @@ namespace PeLib
|
||||
// Invalid leaf.
|
||||
std::uint32_t uiRva = uiRsrcRva + uiOffset;
|
||||
if(uiRva > sizeOfImage)
|
||||
{
|
||||
return ERROR_INVALID_FILE;
|
||||
}
|
||||
|
||||
// Load the resource data entry
|
||||
imageLoader.readImage(&entry, uiRva, sizeof(PELIB_IMAGE_RESOURCE_DATA_ENTRY));
|
||||
@ -330,6 +328,8 @@ namespace PeLib
|
||||
m_data.clear();
|
||||
|
||||
// No data or invalid leaf
|
||||
if(entry.OffsetToData == 0 && entry.Size == 0)
|
||||
return ERROR_INVALID_FILE;
|
||||
if(entry.OffsetToData > sizeOfImage || entry.Size > sizeOfImage)
|
||||
return ERROR_NONE;
|
||||
if((uiRsrcRva + entry.OffsetToData) >= sizeOfImage || (uiRsrcRva + entry.OffsetToData + entry.Size) > sizeOfImage)
|
||||
@ -1031,11 +1031,6 @@ namespace PeLib
|
||||
std::uint32_t resDirRva = imageLoader.getDataDirRva(PELIB_IMAGE_DIRECTORY_ENTRY_RESOURCE);
|
||||
std::uint32_t sizeOfImage = imageLoader.getSizeOfImage();
|
||||
|
||||
if(resDirRva >= sizeOfImage)
|
||||
{
|
||||
return ERROR_INVALID_FILE;
|
||||
}
|
||||
|
||||
return m_rnRoot.read(imageLoader, resDirRva, 0, sizeOfImage, this);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user