[PATCH] D82886: [DebugInfo] Fix a possible crash when reading a malformed .debug_*lists section.

Igor Kudrin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 14 02:36:24 PDT 2020


This revision was automatically updated to reflect the committed changes.
Closed by commit rGec9f0c7d4ae2: [DebugInfo] Fix a possible crash when reading a malformed .debug_*lists section. (authored by ikudrin).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82886/new/

https://reviews.llvm.org/D82886

Files:
  llvm/lib/DebugInfo/DWARF/DWARFListTable.cpp
  llvm/test/DebugInfo/X86/dwarfdump-rnglists-zero-length.s


Index: llvm/test/DebugInfo/X86/dwarfdump-rnglists-zero-length.s
===================================================================
--- /dev/null
+++ llvm/test/DebugInfo/X86/dwarfdump-rnglists-zero-length.s
@@ -0,0 +1,12 @@
+## The test checks that llvm-dwarfdump can handle a malformed input file without
+## crashing.
+
+# RUN: llvm-mc -triple x86_64 %s -filetype=obj -o %t
+# RUN: not llvm-dwarfdump -debug-rnglists %t 2>&1 | FileCheck %s
+
+# CHECK: error: .debug_rnglists table at offset 0x0 has too small length (0x4) to contain a complete header
+
+## An assertion used to trigger in the debug build of the DebugInfo/DWARF 
+## library if the unit length field in a range list table was 0.
+    .section .debug_rnglists,"", at progbits
+    .long 0
Index: llvm/lib/DebugInfo/DWARF/DWARFListTable.cpp
===================================================================
--- llvm/lib/DebugInfo/DWARF/DWARFListTable.cpp
+++ llvm/lib/DebugInfo/DWARF/DWARFListTable.cpp
@@ -29,13 +29,13 @@
   uint8_t OffsetByteSize = Format == dwarf::DWARF64 ? 8 : 4;
   uint64_t FullLength =
       HeaderData.Length + dwarf::getUnitLengthFieldByteSize(Format);
-  assert(FullLength == length());
   if (FullLength < getHeaderSize(Format))
     return createStringError(errc::invalid_argument,
                        "%s table at offset 0x%" PRIx64
                        " has too small length (0x%" PRIx64
                        ") to contain a complete header",
                        SectionName.data(), HeaderOffset, FullLength);
+  assert(FullLength == length() && "Inconsistent calculation of length.");
   uint64_t End = HeaderOffset + FullLength;
   if (!Data.isValidOffsetForDataOfSize(HeaderOffset, FullLength))
     return createStringError(errc::invalid_argument,


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D82886.277722.patch
Type: text/x-patch
Size: 1764 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200714/bc4cedc9/attachment.bin>


More information about the llvm-commits mailing list