+2014-11-16 Mark Wielaard <mjw@redhat.com>
+
+ * elf_getshdrstrndx.c: Check there are section headers before
+ handling SHN_XINDEX.
+
2014-11-16 Mark Wielaard <mjw@redhat.com>
* elf32_getphdr.c (getphdr_wrlock): Check e_phoff isn't zero.
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)
{
}
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;