Index: scanelf.c =================================================================== RCS file: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v retrieving revision 1.184 diff --unified -r1.184 scanelf.c --- scanelf.c 12 Aug 2007 16:35:25 -0000 1.184 +++ scanelf.c 15 Aug 2007 21:12:59 -0000 @@ -358,7 +358,7 @@ Elf ## B ## _Phdr *phdr = PHDR ## B (elf->phdr); \ Elf ## B ## _Off offset; \ for (i = 0; i < EGET(ehdr->e_phnum); i++) { \ - if (EGET(phdr[i].p_type) != PT_DYNAMIC) continue; \ + if (EGET(phdr[i].p_type) != PT_DYNAMIC || EGET(phdr[i].p_filesz) == 0) continue; \ offset = EGET(phdr[i].p_offset); \ if (offset >= elf->len - sizeof(Elf ## B ## _Dyn)) continue; \ dyn = DYN ## B (elf->data + offset); \ @@ -560,7 +560,7 @@ /* Scan all the program headers */ \ for (i = 0; i < EGET(ehdr->e_phnum); i++) { \ /* Just scan dynamic headers */ \ - if (EGET(phdr[i].p_type) != PT_DYNAMIC) continue; \ + if (EGET(phdr[i].p_type) != PT_DYNAMIC || EGET(phdr[i].p_filesz) == 0) continue; \ offset = EGET(phdr[i].p_offset); \ if (offset >= elf->len - sizeof(Elf ## B ## _Dyn)) continue; \ /* Just scan dynamic RPATH/RUNPATH headers */ \ @@ -820,7 +820,7 @@ Elf ## B ## _Shdr *strtbl = SHDR ## B (strtbl_void); \ Elf ## B ## _Off offset; \ for (i = 0; i < EGET(ehdr->e_phnum); i++) { \ - if (EGET(phdr[i].p_type) != PT_DYNAMIC) continue; \ + if (EGET(phdr[i].p_type) != PT_DYNAMIC || EGET(phdr[i].p_filesz) == 0) continue; \ offset = EGET(phdr[i].p_offset); \ if (offset >= elf->len - sizeof(Elf ## B ## _Dyn)) continue; \ dyn = DYN ## B (elf->data + offset); \ @@ -895,7 +895,7 @@ Elf ## B ## _Phdr *phdr = PHDR ## B (elf->phdr); \ Elf ## B ## _Off offset; \ for (i = 0; i < EGET(ehdr->e_phnum); i++) { \ - if (EGET(phdr[i].p_type) != PT_DYNAMIC) continue; \ + if (EGET(phdr[i].p_type) != PT_DYNAMIC || EGET(phdr[i].p_filesz) == 0) continue; \ dynamic = 1; \ offset = EGET(phdr[i].p_offset); \ if (offset >= elf->len - sizeof(Elf ## B ## _Dyn)) continue; \ @@ -947,7 +947,7 @@ if (ehdr->e_type != ET_DYN) \ return NULL; \ for (i = 0; i < EGET(ehdr->e_phnum); i++) { \ - if (EGET(phdr[i].p_type) != PT_DYNAMIC) continue; \ + if (EGET(phdr[i].p_type) != PT_DYNAMIC || EGET(phdr[i].p_filesz) == 0) continue; \ offset = EGET(phdr[i].p_offset); \ if (offset >= elf->len - sizeof(Elf ## B ## _Dyn)) continue; \ dyn = DYN ## B (elf->data + offset); \