Skip to content

Commit

Permalink
Stop at non-conforming Debug Directory entry
Browse files Browse the repository at this point in the history
Debug directory is not necessary for program execution. Sometimes toolchains
put there data not conforming to any standards. It is still possible to
parse the rest of the file, no need to fail parsing with an error.
  • Loading branch information
batuzovk committed Feb 14, 2024
1 parent b43ff37 commit ae4eeab
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions pe-parser-library/src/parse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1881,20 +1881,23 @@ bool getDebugDir(parsed_pe *p) {
rawData =
curEnt.AddressOfRawData + p->peHeader.nt.OptionalHeader64.ImageBase;
} else {
return false;
break;
}

//
// Get the section for the data
//
section dataSec;
if (!getSecForVA(p->internal->secs, rawData, dataSec)) {
return false;
break;
}

debugent ent;

auto dataofft = static_cast<std::uint32_t>(rawData - dataSec.sectionBase);
if (dataofft + curEnt.SizeOfData > dataSec.sectionData->bufLen) {
break;
}
ent.type = curEnt.Type;
ent.data = makeBufferFromPointer(
reinterpret_cast<std::uint8_t *>(dataSec.sectionData->buf + dataofft),
Expand Down

0 comments on commit ae4eeab

Please sign in to comment.