Fix division by zero in prelink detection, issue 420

Avoid dividing by zero when hitting an ELF section without fixed-size
entries.
Thanks to Michael Schroeder for helping trace the problem (in #420)
This commit is contained in:
Bernhard Rosenkränzer 2018-03-27 14:15:51 +02:00 committed by Florian Festi
parent 61d23649cb
commit 2e3867ebce
1 changed files with 1 additions and 1 deletions

View File

@ -54,7 +54,7 @@ static int is_prelinked(int fdno)
while (!prelinked && (scn = elf_nextscn(elf, scn)) != NULL) {
(void) gelf_getshdr(scn, &shdr);
if (shdr.sh_type != SHT_DYNAMIC)
if (shdr.sh_type != SHT_DYNAMIC || shdr.sh_entsize == 0)
continue;
while (!prelinked && (data = elf_getdata (scn, data)) != NULL) {
int maxndx = data->d_size / shdr.sh_entsize;