HomeFreeBSD

elfdump: handle small files more gracefully

Description

elfdump: handle small files more gracefully

elfdump -E on an empty file would complain "Invalid argument" because
it tried to mmap zero bytes. With the -E flag, elfdump should
simply exit non-zero. For tiny files, the code would reference off
the end of the mapped region.

Ensure the file is large enough to contain an ELF header before mapping it.

MFC after: 1 week
Sponsored by: Dell EMC Isilon

(cherry picked from commit 86e5e10daf54da7df358a06033f3a3bd8c852a08)

Details

Provenance
vangyzenAuthored on Feb 17 2022, 3:53 PM
Parents
rG22561b00abac: Integrate contrib/file/tests with kyua/atf
Branches
Unknown
Tags
Unknown