diff options
author | Mark Wielaard <mjw@redhat.com> | 2014-11-17 00:42:53 +0100 |
---|---|---|
committer | Mark Wielaard <mjw@redhat.com> | 2014-11-17 00:42:53 +0100 |
commit | babcdeff28bdf1d5ce26c8aa35fea420921f4ba7 (patch) | |
tree | 5abbd084d299b3cfa6a17c512c1e211f4c917902 /libelf/elf_getshdrstrndx.c | |
parent | 436275edd015ab6a6f8e164ee2292f74f03d2413 (diff) | |
download | elfutils-babcdeff28bdf1d5ce26c8aa35fea420921f4ba7.tar.gz |
libelf: elf_getshdrstrndx cannot use SHN_XINDEX without section headers.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Diffstat (limited to 'libelf/elf_getshdrstrndx.c')
-rw-r--r-- | libelf/elf_getshdrstrndx.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/libelf/elf_getshdrstrndx.c b/libelf/elf_getshdrstrndx.c index 1dbed4c8..6f8d66e8 100644 --- a/libelf/elf_getshdrstrndx.c +++ b/libelf/elf_getshdrstrndx.c @@ -92,6 +92,13 @@ elf_getshdrstrndx (elf, dst) if (elf->class == ELFCLASS32) { size_t offset; + if (unlikely (elf->state.elf32.scns.cnt == 0)) + { + /* Cannot use SHN_XINDEX without section headers. */ + __libelf_seterrno (ELF_E_INVALID_SECTION_HEADER); + result = -1; + goto out; + } if (elf->state.elf32.scns.data[0].shdr.e32 != NULL) { @@ -146,6 +153,14 @@ elf_getshdrstrndx (elf, dst) } else { + if (unlikely (elf->state.elf64.scns.cnt == 0)) + { + /* Cannot use SHN_XINDEX without section headers. */ + __libelf_seterrno (ELF_E_INVALID_SECTION_HEADER); + result = -1; + goto out; + } + if (elf->state.elf64.scns.data[0].shdr.e64 != NULL) { num = elf->state.elf64.scns.data[0].shdr.e64->sh_link; |