[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
This commit is contained in:
Igor Kudrin 2019-12-16 21:16:14 +07:00
parent 3c6554be2e
commit 5279f96577
1 changed files with 2 additions and 2 deletions

View File

@ -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<GenericError>("Malformed DWARF in " + path);
uint16_t version = infoData.getU16(&offset);