diff options
author | Mark Wielaard <mark@klomp.org> | 2018-10-18 19:01:52 +0200 |
---|---|---|
committer | Mark Wielaard <mark@klomp.org> | 2018-10-20 00:13:09 +0200 |
commit | 2b16a9be69939822dcafe075413468daac98b327 (patch) | |
tree | f20bfa91d71a0b7bbe878d4a63e57ef4b3709385 | |
parent | 4cdb0fd0d3b4255a9994ce302d6df76d251f7b75 (diff) |
arlib: Check that sh_entsize isn't zero.
A bogus ELF file could have sh_entsize as zero. Don't divide by zero,
but just assume there are no symbols in the section.
https://sourceware.org/bugzilla/show_bug.cgi?id=23786
Signed-off-by: Mark Wielaard <mark@klomp.org>
-rw-r--r-- | src/ChangeLog | 4 | ||||
-rw-r--r-- | src/arlib.c | 3 |
2 files changed, 7 insertions, 0 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 40de5a09..92beb1bb 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +2018-10-18 Mark Wielaard <mark@klomp.org> + + * arlib.c (arlib_add_symbols): Check that sh_entsize is not zero. + 2018-10-14 Mark Wielaard <mark@klomp.org> * ar.c (do_oper_extract): Assume epoch if ar_date is bogus. diff --git a/src/arlib.c b/src/arlib.c index 778e0878..a6521e30 100644 --- a/src/arlib.c +++ b/src/arlib.c @@ -252,6 +252,9 @@ arlib_add_symbols (Elf *elf, const char *arfname, const char *membername, if (data == NULL) continue; + if (shdr->sh_entsize == 0) + continue; + int nsyms = shdr->sh_size / shdr->sh_entsize; for (int ndx = shdr->sh_info; ndx < nsyms; ++ndx) { |