summaryrefslogtreecommitdiffstats
path: root/libelf/gelf_getphdr.c
diff options
context:
space:
mode:
Diffstat (limited to 'libelf/gelf_getphdr.c')
-rw-r--r--libelf/gelf_getphdr.c19
1 files changed, 6 insertions, 13 deletions
diff --git a/libelf/gelf_getphdr.c b/libelf/gelf_getphdr.c
index 3bf7123f..c719e4be 100644
--- a/libelf/gelf_getphdr.c
+++ b/libelf/gelf_getphdr.c
@@ -1,5 +1,5 @@
/* Return program header table entry.
- Copyright (C) 1998-2010 Red Hat, Inc.
+ Copyright (C) 1998-2010, 2015 Red Hat, Inc.
This file is part of elfutils.
Written by Ulrich Drepper <drepper@redhat.com>, 1998.
@@ -39,10 +39,7 @@
GElf_Phdr *
-gelf_getphdr (elf, ndx, dst)
- Elf *elf;
- int ndx;
- GElf_Phdr *dst;
+gelf_getphdr (Elf *elf, int ndx, GElf_Phdr *dst)
{
GElf_Phdr *result = NULL;
@@ -80,10 +77,8 @@ gelf_getphdr (elf, ndx, dst)
/* Test whether the index is ok. */
size_t phnum;
- if (ndx >= elf->state.elf32.ehdr->e_phnum
- && (elf->state.elf32.ehdr->e_phnum != PN_XNUM
- || __elf_getphdrnum_rdlock (elf, &phnum) != 0
- || (size_t) ndx >= phnum))
+ if (__elf_getphdrnum_chk_rdlock (elf, &phnum) != 0
+ || (size_t) ndx >= phnum)
{
__libelf_seterrno (ELF_E_INVALID_INDEX);
goto out;
@@ -122,10 +117,8 @@ gelf_getphdr (elf, ndx, dst)
/* Test whether the index is ok. */
size_t phnum;
- if (ndx >= elf->state.elf64.ehdr->e_phnum
- && (elf->state.elf64.ehdr->e_phnum != PN_XNUM
- || __elf_getphdrnum_rdlock (elf, &phnum) != 0
- || (size_t) ndx >= phnum))
+ if (__elf_getphdrnum_chk_rdlock (elf, &phnum) != 0
+ || (size_t) ndx >= phnum)
{
__libelf_seterrno (ELF_E_INVALID_INDEX);
goto out;