From 5279f96577af1457a973c071ec5ee3554c9f6cbe Mon Sep 17 00:00:00 2001 From: Igor Kudrin Date: Mon, 16 Dec 2019 21:16:14 +0700 Subject: [PATCH] [MachO] Fix detecting malformed DWARF. This fixes an invalid constant used to detect the reserved range when reading the compilation unit header. See also: D64622 and D65039. Differential Revision: https://reviews.llvm.org/D71546 --- lld/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lld/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp b/lld/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp index 0163c90189fd..6f294b1ecd0f 100644 --- a/lld/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp +++ b/lld/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp @@ -879,11 +879,11 @@ readCompUnit(const NormalizedFile &normalizedFile, 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("Malformed DWARF in " + path); uint16_t version = infoData.getU16(&offset);