Skip to content

Commit

Permalink
Merge pull request avast#1166 from avast/dotnet-looping
Browse files Browse the repository at this point in the history
Fix .NET parser trying to read strings from String stream when out-of-bounds of the file
  • Loading branch information
HoundThe authored Jul 18, 2023
2 parents ac20bb0 + d3a2f15 commit f7e82bb
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/fileformat/file_format/pe/pe_format.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2593,6 +2593,13 @@ void PeFormat::parseStringStream(std::uint64_t baseAddress, std::uint64_t offset
while (currentOffset < size)
{
std::string string;
std::uint64_t c = 0;
auto successful_read = get1Byte(address + currentOffset, c, getEndianness());
// If the reading fails (OOB or other) don't continue and terminate
if (!successful_read)
{
break;
}
getNTBS(address + currentOffset, string);
stringStream->addString(currentOffset, string);
// +1 for null-terminator
Expand Down

0 comments on commit f7e82bb

Please sign in to comment.