]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
arlib: Check that sh_entsize isn't zero.
authorMark Wielaard <mark@klomp.org>
Thu, 18 Oct 2018 17:01:52 +0000 (19:01 +0200)
committerMark Wielaard <mark@klomp.org>
Fri, 19 Oct 2018 22:13:09 +0000 (00:13 +0200)
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>
src/ChangeLog
src/arlib.c

index 40de5a09503494da0cc8b8badd241f89c1b6218a..92beb1bbf1c20063a7944dbb48b522d022917133 100644 (file)
@@ -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.
index 778e0878b31ecc3aef8790946ece2939f04d2333..a6521e307b11c86a7e612a7a72eab0c510c90fa3 100644 (file)
@@ -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)
        {