c0e8f3
commit f03ac75239e0981deaf4aa18f66f423bcc5ce051
c0e8f3
Author: Mark Wielaard <mark@klomp.org>
c0e8f3
Date:   Wed Mar 27 21:54:06 2019 +0100
c0e8f3
c0e8f3
    strip: Files with symbols referring to non-existing sections are illformed
c0e8f3
    
c0e8f3
    The check added in commit 4540ea98c "strip: Fix check test for SHN_XINDEX
c0e8f3
    symbol" was not complete. The (extended) section index should also exist.
c0e8f3
    If it doesn't exist, mark the file as illformed.
c0e8f3
    
c0e8f3
    https://sourceware.org/bugzilla/show_bug.cgi?id=24385
c0e8f3
    
c0e8f3
    Signed-off-by: Mark Wielaard <mark@klomp.org>
c0e8f3
c0e8f3
diff --git a/src/strip.c b/src/strip.c
c0e8f3
index a73009d9..4cd87506 100644
c0e8f3
--- a/src/strip.c
c0e8f3
+++ b/src/strip.c
c0e8f3
@@ -1975,6 +1975,7 @@ handle_elf (int fd, Elf *elf, const char *prefix, const char *fname,
c0e8f3
 				  && shndxdata->d_buf != NULL);
c0e8f3
 		    size_t sidx = (sym->st_shndx != SHN_XINDEX
c0e8f3
 				   ? sym->st_shndx : xshndx);
c0e8f3
+		    elf_assert (sidx < shnum);
c0e8f3
 		    sec = shdr_info[sidx].idx;
c0e8f3
 
c0e8f3
 		    if (sec != 0)