Skip to content

Commit

Permalink
loader/elf: fix abort on broken binary (#239)
Browse files Browse the repository at this point in the history
  • Loading branch information
Michal Bandzi committed Mar 13, 2018
1 parent 8dc010c commit 2e6ecef
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/loader/loader/elf/elf_image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,15 @@ ElfImage::SegmentToSectionsTable ElfImage::createSegmentToSectionsTable()
std::uint64_t address = elfSeg->getAddress();
std::uint64_t fileOffset = elfSeg->getOffset();
std::uint64_t fileSize = elfSeg->getLoadedSize();
retdec::utils::Range<std::uint64_t> segRange = retdec::utils::Range<std::uint64_t>(address, address + (memSize ? memSize - 1 : 0));
std::uint64_t endAddress = address + (memSize ? memSize - 1 : 0);

if (address > endAddress)
{
// Invalid data - return only partially loaded map
return segToSecsTable;
}

retdec::utils::Range<std::uint64_t> segRange = retdec::utils::Range<std::uint64_t>(address, endAddress);

for (const auto& sec : sections)
{
Expand Down

0 comments on commit 2e6ecef

Please sign in to comment.