summaryrefslogtreecommitdiff
path: root/lib/DebugInfo
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
commitd5468bf381a8e2c18c50f7e8e7804ad3e04ce66c (patch)
treee96a15c1cc7b1626a72f061a1ef91923498c0d4b /lib/DebugInfo
parent69bc4ddf101663a0b4f23dec25a6f2a2a76699f6 (diff)
downloadllvm-d5468bf381a8e2c18c50f7e8e7804ad3e04ce66c.tar.gz
llvm-d5468bf381a8e2c18c50f7e8e7804ad3e04ce66c.tar.bz2
llvm-d5468bf381a8e2c18c50f7e8e7804ad3e04ce66c.tar.xz
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@201179 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/DebugInfo')
-rw-r--r--lib/DebugInfo/DWARFDebugLoc.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/DebugInfo/DWARFDebugLoc.cpp b/lib/DebugInfo/DWARFDebugLoc.cpp
index 3895ffa8d7..36d17919de 100644
--- a/lib/DebugInfo/DWARFDebugLoc.cpp
+++ b/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";
}