make llvm-dwarfdump a little more resilient when parsing .debug_loc

sections. The call to data.getUnsigned(&Offset, AddressSize) only
increments Offset if the read succeeds, which will result in an infinite
loop.

llvm-svn: 201179
This commit is contained in:
Adrian Prantl 2014-02-11 21:22:53 +00:00
parent 68ccb3b6de
commit 6f84d31540
1 changed files with 3 additions and 1 deletions

View File

@ -36,7 +36,7 @@ void DWARFDebugLoc::dump(raw_ostream &OS) const {
void DWARFDebugLoc::parse(DataExtractor data, unsigned AddressSize) {
uint32_t Offset = 0;
while (data.isValidOffset(Offset)) {
while (data.isValidOffset(Offset+AddressSize-1)) {
Locations.resize(Locations.size() + 1);
LocationList &Loc = Locations.back();
Loc.Offset = Offset;
@ -71,4 +71,6 @@ void DWARFDebugLoc::parse(DataExtractor data, unsigned AddressSize) {
Loc.Entries.push_back(llvm_move(E));
}
}
if (data.isValidOffset(Offset))
llvm::errs() << "error: failed to consume entire .debug_loc section\n";
}