Skip to content

Commit

Permalink
[MachO] Fix detecting malformed DWARF.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
igorkudrin committed Dec 17, 2019
1 parent 3c6554b commit 5279f96
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lld/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp
Expand Up @@ -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);
Expand Down

0 comments on commit 5279f96

Please sign in to comment.