[llvm-readobj] Re-add sanity checking which was accidentally removed in r241764
authorDavid Majnemer <david.majnemer@gmail.com>
Thu, 9 Jul 2015 18:14:31 +0000 (18:14 +0000)
committerDavid Majnemer <david.majnemer@gmail.com>
Thu, 9 Jul 2015 18:14:31 +0000 (18:14 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@241831 91177308-0d34-0410-b5e6-96231b3b80d8

tools/llvm-readobj/COFFDumper.cpp

index ccb542e37e5af6b940c7e33a4449e0b1cc960907..cf897d7cb48404dca640a8575f77cf0206697af6 100644 (file)
@@ -597,8 +597,15 @@ void COFFDumper::printCodeViewDebugInfo(const SectionRef &Section) {
       // in the line table.  The filename string is accessed using double
       // indirection to the string table subsection using the index subsection.
       uint32_t OffsetInIndex = DE.getU32(&Offset),
-               SegmentLength = DE.getU32(&Offset);
-      Offset += sizeof(uint32_t); // Skip FullSegmentSize
+               SegmentLength = DE.getU32(&Offset),
+               FullSegmentSize = DE.getU32(&Offset);
+
+      if (FullSegmentSize !=
+          12 + 8 * SegmentLength +
+              (HasColumnInformation ? 4 * SegmentLength : 0)) {
+        error(object_error::parse_failed);
+        return;
+      }
 
       uint32_t FilenameOffset;
       {