llvm-project
d2dc6413 - [Object][COFF] Bounds-check the PE signature offset in COFFObjectFile (#246158)

Commit
2 days ago
[Object][COFF] Bounds-check the PE signature offset in COFFObjectFile (#246158) `lldb-target-fuzzer` finds a crash, which can be reproduced this way: ``` $ python3 -c "import sys; sys.stdout.buffer.write(b'MZ' + bytes(58) + (0x2020).to_bytes(4, 'little'))" > /tmp/pe-lfanew.bin $ lldb -b -o "target create /tmp/pe-lfanew.bin" (lldb) target create /tmp/pe-lfanew.bin ==49182==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x616000dd09e0 READ of size 4 at 0x616000dd09e0 thread T0 #1 0x000106262640 in memcmp #2 0x0070160a7f2c in llvm::object::COFFObjectFile::initialize() #3 0x0070160a783c in llvm::object::COFFObjectFile::create(llvm::MemoryBufferRef) #4 0x007001d63270 in ObjectFilePECOFF::GetModuleSpecifications(...) 0x616000dd09e0 is located 7708 bytes after 580-byte region [0x616000dce980,0x616000dcebc4) ``` This commit is to add `checkSize` before the `memcmp`, the helper `initialize()` already uses for its other size checks. Assited-by: Claude
Author
Parents
Loading