GCC10 -fanalyzer with -flto notices __elf64_getshdr_rdlock can fail
and because the result isn't checked in elf_strptr it can cause a
dereference of NULL.
Signed-off-by: Mark Wielaard <mark@klomp.org>
+2020-05-08 Mark Wielaard <mark@klomp.org>
+
+ * elf_strptr.c (elf_strptr): Check shdr is not NULL.
+
2020-05-08 Mark Wielaard <mark@klomp.org>
* elf_getdata.c (__libelf_set_rawdata_wrlock): Check
else
{
Elf64_Shdr *shdr = strscn->shdr.e64 ?: __elf64_getshdr_rdlock (strscn);
- if (unlikely (shdr->sh_type != SHT_STRTAB))
+ if (unlikely (shdr == NULL || shdr->sh_type != SHT_STRTAB))
{
/* This is no string section. */
__libelf_seterrno (ELF_E_INVALID_SECTION);