[PATCH] D71546: [MachO] Fix detecting malformed DWARF.

Igor Kudrin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 16 06:35:53 PST 2019


ikudrin created this revision.
ikudrin added reviewers: lhames, ruiu.
ikudrin added a project: lld.
Herald added a project: LLVM.

This fixes an invalid constant used to detect the reserved range when reading the compilation unit header.

See also: D64622 <https://reviews.llvm.org/D64622> and D65039 <https://reviews.llvm.org/D65039>.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D71546

Files:
  lld/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp


Index: lld/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp
===================================================================
--- lld/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp
+++ lld/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp
@@ -879,11 +879,11 @@
   llvm::dwarf::DwarfFormat Format = llvm::dwarf::DwarfFormat::DWARF32;
   auto infoData = dataExtractorFromSection(normalizedFile, info);
   uint32_t length = infoData.getU32(&offset);
-  if (length == 0xffffffff) {
+  if (length == llvm::dwarf::DW_LENGTH_DWARF64) {
     Format = llvm::dwarf::DwarfFormat::DWARF64;
     infoData.getU64(&offset);
   }
-  else if (length > 0xffffff00)
+  else if (length >= llvm::dwarf::DW_LENGTH_lo_reserved)
     return llvm::make_error<GenericError>("Malformed DWARF in " + path);
 
   uint16_t version = infoData.getU16(&offset);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D71546.234048.patch
Type: text/x-patch
Size: 847 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191216/5b777dd4/attachment.bin>


More information about the llvm-commits mailing list