diff options
author | Mark Wielaard <mark@klomp.org> | 2020-11-01 18:52:15 +0100 |
---|---|---|
committer | Mark Wielaard <mark@klomp.org> | 2020-11-06 18:39:40 +0100 |
commit | f31e45b1456b551ef8ee4711b06280a58954d980 (patch) | |
tree | cf1efb692663e262ff14c64f2cb8ce46aec78f94 /libelf | |
parent | 86cedebad363184ef5e4e4f51e1ee2f701e32ad3 (diff) | |
download | elfutils-f31e45b1456b551ef8ee4711b06280a58954d980.tar.gz |
libelf: Check header exists in elf_strptr
We already checked the header actually existed for ELFCLASS64 but not
for the ELFCLASS32 case. It is very unlikely it is at this point in the
code, but theoretically it could happen.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Diffstat (limited to 'libelf')
-rw-r--r-- | libelf/ChangeLog | 4 | ||||
-rw-r--r-- | libelf/elf_strptr.c | 2 |
2 files changed, 5 insertions, 1 deletions
diff --git a/libelf/ChangeLog b/libelf/ChangeLog index aee1ffff..db3eed08 100644 --- a/libelf/ChangeLog +++ b/libelf/ChangeLog @@ -1,5 +1,9 @@ 2020-11-01 Mark Wielaard <mark@klomp.org> + * elf_strptr.c (elf_strptr): Check shdr is not NULL. + +2020-11-01 Mark Wielaard <mark@klomp.org> + * elf_getphdrnum.c (__elf_getphdrnum_rdlock): Set *dst to zero on error. diff --git a/libelf/elf_strptr.c b/libelf/elf_strptr.c index c7271707..76f2caf1 100644 --- a/libelf/elf_strptr.c +++ b/libelf/elf_strptr.c @@ -119,7 +119,7 @@ elf_strptr (Elf *elf, size_t idx, size_t offset) if (elf->class == ELFCLASS32) { Elf32_Shdr *shdr = strscn->shdr.e32 ?: __elf32_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); |