libelf: Set dst to zero on failure in __elf_getphdrnum_rdlock
authorMark Wielaard <mark@klomp.org>
Sun, 1 Nov 2020 17:51:02 +0000 (18:51 +0100)
committerMark Wielaard <mark@klomp.org>
Fri, 6 Nov 2020 17:39:40 +0000 (18:39 +0100)
commit86cedebad363184ef5e4e4f51e1ee2f701e32ad3
treef2245a6acf3890626b7e7e31704187243b0b8624
parentf2272dbefd6dbd67af4d46eb6e748522c0c60d74
libelf: Set dst to zero on failure in __elf_getphdrnum_rdlock

GCC with -flto finds some (very) unlikely error paths. It flags callers
of __elf_getphdrnum_chk_rdlock with *dst not yet set because an internal
call to __elf_getphdrnum_rdlock might not initialize *dst either in one
particular failure path. The sanity check that __elf_getphdrnum_chk_rdlock
then performs might happen against uninitialized data. So just set *dst
to zero on failure in __elf_getphdrnum_rdlock so any caller can simply
check either the result/error code or whether *dst is zero or not.

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