mirror of
https://github.com/openharmony/third_party_elfutils.git
synced 2026-07-16 07:44:26 -04:00
libelf: elf_getshdrstrndx cannot use SHN_XINDEX without section headers.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
This commit is contained in:
@@ -1,3 +1,8 @@
|
||||
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.
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user