summaryrefslogtreecommitdiff
path: root/libelf/gelf_update_lib.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2014-01-17 20:38:01 +0100
committerMark Wielaard <mjw@redhat.com>2014-01-23 11:31:53 +0100
commita9039623c272f458a53f09009c2a0e1d6e60491d (patch)
tree89fbb96c4a083aaecf960871e02a4fd99085245f /libelf/gelf_update_lib.c
parent720383c53b435de6647edd78060dd7d38ade25a5 (diff)
downloadelfutils-a9039623c272f458a53f09009c2a0e1d6e60491d.tar.gz
robustify: libelf gelf define INVALID_NDX macro.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Diffstat (limited to 'libelf/gelf_update_lib.c')
-rw-r--r--libelf/gelf_update_lib.c10
1 files changed, 2 insertions, 8 deletions
diff --git a/libelf/gelf_update_lib.c b/libelf/gelf_update_lib.c
index 4700bef8..1c8c23da 100644
--- a/libelf/gelf_update_lib.c
+++ b/libelf/gelf_update_lib.c
@@ -1,5 +1,5 @@
/* Update library in table at the given index.
- Copyright (C) 2004 Red Hat, Inc.
+ Copyright (C) 2004, 2005, 2009, 2014 Red Hat, Inc.
This file is part of elfutils.
Written by Ulrich Drepper <drepper@redhat.com>, 2004.
@@ -47,12 +47,6 @@ gelf_update_lib (data, ndx, src)
if (data == NULL)
return 0;
- if (unlikely (ndx < 0))
- {
- __libelf_seterrno (ELF_E_INVALID_INDEX);
- return 0;
- }
-
Elf_Data_Scn *data_scn = (Elf_Data_Scn *) data;
if (unlikely (data_scn->d.d_type != ELF_T_LIB))
{
@@ -66,7 +60,7 @@ gelf_update_lib (data, ndx, src)
/* Check whether we have to resize the data buffer. */
int result = 0;
- if (unlikely ((ndx + 1) * sizeof (Elf64_Lib) > data_scn->d.d_size))
+ if (INVALID_NDX (ndx, Elf64_Lib, &data_scn->d))
__libelf_seterrno (ELF_E_INVALID_INDEX);
else
{