diff options
| author | Jakub Jelinek <[email protected]> | 2014-01-17 20:38:01 +0100 |
|---|---|---|
| committer | Mark Wielaard <[email protected]> | 2014-01-23 11:31:53 +0100 |
| commit | a9039623c272f458a53f09009c2a0e1d6e60491d (patch) | |
| tree | 89fbb96c4a083aaecf960871e02a4fd99085245f /libelf/gelf_update_symshndx.c | |
| parent | 720383c53b435de6647edd78060dd7d38ade25a5 (diff) | |
robustify: libelf gelf define INVALID_NDX macro.
Signed-off-by: Mark Wielaard <[email protected]>
Diffstat (limited to 'libelf/gelf_update_symshndx.c')
| -rw-r--r-- | libelf/gelf_update_symshndx.c | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/libelf/gelf_update_symshndx.c b/libelf/gelf_update_symshndx.c index d2bb5bbe..5e2c7f70 100644 --- a/libelf/gelf_update_symshndx.c +++ b/libelf/gelf_update_symshndx.c @@ -1,6 +1,6 @@ /* Update symbol information and section index in symbol table at the 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. @@ -56,12 +56,6 @@ gelf_update_symshndx (symdata, shndxdata, ndx, src, srcshndx) if (symdata == NULL) return 0; - if (unlikely (ndx < 0)) - { - __libelf_seterrno (ELF_E_INVALID_INDEX); - return 0; - } - if (unlikely (symdata_scn->d.d_type != ELF_T_SYM)) { /* The type of the data better should match. */ @@ -107,7 +101,7 @@ gelf_update_symshndx (symdata, shndxdata, ndx, src, srcshndx) } /* Check whether we have to resize the data buffer. */ - if (unlikely ((ndx + 1) * sizeof (Elf32_Sym) > symdata_scn->d.d_size)) + if (INVALID_NDX (ndx, Elf32_Sym, &symdata_scn->d)) { __libelf_seterrno (ELF_E_INVALID_INDEX); goto out; @@ -130,7 +124,7 @@ gelf_update_symshndx (symdata, shndxdata, ndx, src, srcshndx) else { /* Check whether we have to resize the data buffer. */ - if (unlikely ((ndx + 1) * sizeof (Elf64_Sym) > symdata_scn->d.d_size)) + if (INVALID_NDX (ndx, Elf64_Sym, &symdata_scn->d)) { __libelf_seterrno (ELF_E_INVALID_INDEX); goto out; |
