OSDN Git Service

[COFFDumper] Validate that the next offset is not too large
authorDavid Majnemer <david.majnemer@gmail.com>
Sat, 28 May 2016 20:04:50 +0000 (20:04 +0000)
committerDavid Majnemer <david.majnemer@gmail.com>
Sat, 28 May 2016 20:04:50 +0000 (20:04 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271147 91177308-0d34-0410-b5e6-96231b3b80d8

tools/llvm-readobj/COFFDumper.cpp

index a216a05..029674b 100644 (file)
@@ -736,6 +736,8 @@ void COFFDumper::printCodeViewSymbolSection(StringRef SectionName,
     size_t SectionOffset = Data.data() - SectionContents.data();
     size_t NextOffset = SectionOffset + SubSectionSize;
     NextOffset = alignTo(NextOffset, 4);
+    if (NextOffset > SectionContents.size())
+      return error(object_error::parse_failed);
     Data = SectionContents.drop_front(NextOffset);
 
     // Optionally print the subsection bytes in case our parsing gets confused