summaryrefslogtreecommitdiffstats
path: root/libelf/gelf_update_rela.c
diff options
context:
space:
mode:
Diffstat (limited to 'libelf/gelf_update_rela.c')
-rw-r--r--libelf/gelf_update_rela.c12
1 files changed, 3 insertions, 9 deletions
diff --git a/libelf/gelf_update_rela.c b/libelf/gelf_update_rela.c
index cc70297e..88252703 100644
--- a/libelf/gelf_update_rela.c
+++ b/libelf/gelf_update_rela.c
@@ -1,5 +1,5 @@
/* Update RELA relocation information at given index.
- Copyright (C) 2000, 2001, 2002 Red Hat, Inc.
+ Copyright (C) 2000, 2001, 2002, 2005, 2009, 2014 Red Hat, Inc.
This file is part of elfutils.
Written by Ulrich Drepper <[email protected]>, 2000.
@@ -47,12 +47,6 @@ gelf_update_rela (Elf_Data *dst, int ndx, GElf_Rela *src)
if (dst == NULL)
return 0;
- if (unlikely (ndx < 0))
- {
- __libelf_seterrno (ELF_E_INVALID_INDEX);
- return 0;
- }
-
if (unlikely (data_scn->d.d_type != ELF_T_RELA))
{
/* The type of the data better should match. */
@@ -80,7 +74,7 @@ gelf_update_rela (Elf_Data *dst, int ndx, GElf_Rela *src)
}
/* Check whether we have to resize the data buffer. */
- 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);
goto out;
@@ -96,7 +90,7 @@ gelf_update_rela (Elf_Data *dst, int ndx, GElf_Rela *src)
else
{
/* Check whether we have to resize the data buffer. */
- 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);
goto out;