summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdrian Prantl <aprantl@apple.com>2014-02-11 21:22:53 +0000
committerAdrian Prantl <aprantl@apple.com>2014-02-11 21:22:53 +0000
commit6f84d31540e2c34faea5f98aec0d63fc9500590e (patch)
tree6b631cbc1e6c31fb3140de09aac3e4aacbeb5d9f
parent68ccb3b6de5acd58ed619bea9c4918fc370171b7 (diff)
downloadbcm5719-llvm-6f84d31540e2c34faea5f98aec0d63fc9500590e.tar.gz
bcm5719-llvm-6f84d31540e2c34faea5f98aec0d63fc9500590e.zip
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
-rw-r--r--llvm/lib/DebugInfo/DWARFDebugLoc.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/llvm/lib/DebugInfo/DWARFDebugLoc.cpp b/llvm/lib/DebugInfo/DWARFDebugLoc.cpp
index 3895ffa8d7a..36d17919dea 100644
--- a/llvm/lib/DebugInfo/DWARFDebugLoc.cpp
+++ b/llvm/lib/DebugInfo/DWARFDebugLoc.cpp
@@ -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";
}
OpenPOWER on IntegriCloud