Skip to content
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
14 changes: 10 additions & 4 deletions src/coreclr/utilcode/pedecoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,6 @@ CHECK PEDecoder::CheckRva(RVA rva, COUNT_T size, int forbiddenFlags, IsNullOK ok
CHECK(section != NULL);

CHECK(CheckBounds(VAL32(section->VirtualAddress),
// AlignUp((UINT)VAL32(section->Misc.VirtualSize), (UINT)VAL32(FindNTHeaders()->OptionalHeader.SectionAlignment)),
(UINT)VAL32(section->Misc.VirtualSize),
rva, size));
if(!IsMapped())
Expand Down Expand Up @@ -776,9 +775,17 @@ IMAGE_SECTION_HEADER *PEDecoder::RvaToSection(RVA rva) const

while (section < sectionEnd)
{
if (rva < (VAL32(section->VirtualAddress)
+ AlignUp((UINT)VAL32(section->Misc.VirtualSize), (UINT)VAL32(FindNTHeaders()->OptionalHeader.SectionAlignment))))
// The RVA should be within a section's virtual address range.
if (rva < (VAL32(section->VirtualAddress) + VAL32(section->Misc.VirtualSize)))
{
if (!IsMapped())
{
// On flat images (!IsMapped()), the RVA should also be within the section's raw data range.
if (rva >= (VAL32(section->VirtualAddress) + VAL32(section->SizeOfRawData)))
{
return NULL;
}
}
if (rva < VAL32(section->VirtualAddress))
RETURN NULL;
else
Expand Down Expand Up @@ -847,7 +854,6 @@ TADDR PEDecoder::GetRvaData(RVA rva, IsNullOK ok /*= NULL_NOT_OK*/) const
offset = rva;
else
{
// !!! check for case where rva is in padded portion of segment
offset = RvaToOffset(rva);
}

Expand Down
Loading