]> git.ipfire.org Git - thirdparty/elfutils.git/commit
libelf, readelf: Use validate_str also to check dynamic symstr data
authorMark Wielaard <mark@klomp.org>
Sat, 8 Feb 2025 20:44:56 +0000 (21:44 +0100)
committerMark Wielaard <mark@klomp.org>
Fri, 14 Feb 2025 07:55:10 +0000 (08:55 +0100)
commit5e5c0394d82c53e97750fe7b18023e6f84157b81
tree2fba85302b4fbfd33e412534a922907d869d04ce
parent2636426a091bd6c6f7f02e49ab20d4cdc6bfc753
libelf, readelf: Use validate_str also to check dynamic symstr data

When dynsym/str was read through eu-readelf --dynamic by readelf
process_symtab the string data was not validated, possibly printing
unallocated memory past the end of the symstr data. Fix this by
turning the elf_strptr validate_str function into a generic
lib/system.h helper function and use it in readelf to validate the
strings before use.

* libelf/elf_strptr.c (validate_str): Remove to...
* lib/system.h (validate_str): ... here. Make inline, simplify
check and document.
* src/readelf.c (process_symtab): Use validate_str on symstr_data.

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

Signed-off-by: Mark Wielaard <mark@klomp.org>
lib/system.h
libelf/elf_strptr.c
src/readelf.c