]> git.ipfire.org Git - thirdparty/elfutils.git/commit
libdwfl: fix OOB read in elf_from_remote_memory phdr check
authorMatej Smycka <matejsmycka@gmail.com>
Fri, 19 Jun 2026 22:06:50 +0000 (00:06 +0200)
committerMark Wielaard <mark@klomp.org>
Sun, 21 Jun 2026 13:45:51 +0000 (15:45 +0200)
commit9fbaee94b78fe9d05ef6cd53691bbcb702ccc478
tree7dfcc63e84e3fa8106f9eb2a2560392e6d714a0d
parent22046fea9ad58919ee3c53371d2725dceb0abfe2
libdwfl: fix OOB read in elf_from_remote_memory phdr check

phoff (e_phoff) comes straight from the untrusted file header, and the
sum is computed in unsigned 64-bit with no overflow check.

* libdwfl/elf-from-memory.c (elf_from_remote_memory): Use an
overflow-safe bound when checking whether the phdrs are already
in the initial read.
* tests/elf-from-memory.c: New file.
* tests/Makefile.am (check_PROGRAMS): Add elf-from-memory.
(TESTS): Likewise.
(elf_from_memory_LDADD): New variable.

Signed-off-by: Matej Smycka <matejsmycka@gmail.com>
libdwfl/elf-from-memory.c
tests/Makefile.am
tests/elf-from-memory.c [new file with mode: 0644]