]> git.ipfire.org Git - thirdparty/elfutils.git/commit
libelf: elf[32|64]_offscn shouldn't return a result for empty sections
authorMark Wielaard <mark@klomp.org>
Tue, 14 Oct 2025 16:21:54 +0000 (18:21 +0200)
committerMark Wielaard <mark@klomp.org>
Wed, 15 Oct 2025 13:57:05 +0000 (15:57 +0200)
commit4e2c5051cf3d0540e7c0612a618271cb8ae7bfdc
treeb522eadc0a347421ad1558209e1cf98225b01ef8
parentc5fa0eb29c1d8b818ee48796042f292c3a80e288
libelf: elf[32|64]_offscn shouldn't return a result for empty sections

offscn sets the result before checking the section isn't empty. It
assumes the result will be reset for the next section that matches the
given offset. But this might not be the case, for example if this was
the last section. It will then return that section (and set elf_errno)
instead of returning NULL to indicate no non-empty section matched.

* libelf/elf32_offscn.c (offscn): Move assignment to result
after empty size check.

Signed-off-by: Mark Wielaard <mark@klomp.org>
libelf/elf32_offscn.c