summaryrefslogtreecommitdiffstats
path: root/libelf/gelf_getrela.c
diff options
context:
space:
mode:
Diffstat (limited to 'libelf/gelf_getrela.c')
-rw-r--r--libelf/gelf_getrela.c12
1 files changed, 3 insertions, 9 deletions
diff --git a/libelf/gelf_getrela.c b/libelf/gelf_getrela.c
index 1d0e7eee..aae8c2be 100644
--- a/libelf/gelf_getrela.c
+++ b/libelf/gelf_getrela.c
@@ -1,5 +1,5 @@
/* Get RELA relocation information at given index.
- Copyright (C) 2000, 2001, 2002 Red Hat, Inc.
+ Copyright (C) 2000-2009 Red Hat, Inc.
This file is part of elfutils.
Written by Ulrich Drepper <[email protected]>, 2000.
@@ -50,12 +50,6 @@ gelf_getrela (data, ndx, dst)
if (data_scn == NULL)
return NULL;
- if (unlikely (ndx < 0))
- {
- __libelf_seterrno (ELF_E_INVALID_INDEX);
- return NULL;
- }
-
if (unlikely (data_scn->d.d_type != ELF_T_RELA))
{
__libelf_seterrno (ELF_E_INVALID_HANDLE);
@@ -72,7 +66,7 @@ gelf_getrela (data, ndx, dst)
if (scn->elf->class == ELFCLASS32)
{
/* We have to convert the data. */
- if (unlikely ((ndx + 1) * sizeof (Elf32_Rela) > data_scn->d.d_size))
+ if (INVALID_NDX (ndx, Elf32_Rela, &data_scn->d))
{
__libelf_seterrno (ELF_E_INVALID_INDEX);
result = NULL;
@@ -93,7 +87,7 @@ gelf_getrela (data, ndx, dst)
{
/* Simply copy the data after we made sure we are actually getting
correct data. */
- if (unlikely ((ndx + 1) * sizeof (Elf64_Rela) > data_scn->d.d_size))
+ if (INVALID_NDX (ndx, Elf64_Rela, &data_scn->d))
{
__libelf_seterrno (ELF_E_INVALID_INDEX);
result = NULL;