]> git.ipfire.org Git - thirdparty/elfutils.git/commit
libelf: elf_update should make sure section zero exists
authorMark Wielaard <mark@klomp.org>
Sat, 7 Mar 2026 14:55:48 +0000 (15:55 +0100)
committerMark Wielaard <mark@klomp.org>
Tue, 10 Mar 2026 14:00:27 +0000 (15:00 +0100)
commite91caaa8fcf51b8484b4a47df317d3362e462c37
tree0fbcca14884537164c29d44b14bc3e858c636a1d
parent269efcc9bd5eccf074bd0e24df1d594dbae67539
libelf: elf_update should make sure section zero exists

elf_update might crash for 65280+ sections when section zero headers
aren't loaded. Make sure section zero is loaded before trying to write
to it.

Add testcase to tests/test-manyfuncs.c but use ELF_C_READ_MMAP_PRIVATE
to workaround https://sourceware.org/bugzilla/show_bug.cgi?id=33968

* libelf/elf32_updatenull.c (updatenull_wrlock): Call
getshdr_wrlock to load shdr.
* tests/test-manyfuncs.c (check_elf): Use elf_begin with
        ELF_C_READ_MMAP_PRIVATE if use_mmap. Call elf_update early.

https://sourceware.org/bugzilla/show_bug.cgi?id=33967

Signed-off-by: Mark Wielaard <mark@klomp.org>
libelf/elf32_updatenull.c
tests/test-manyfuncs.c