Fix bad elf data handling.
am: 66013410e8

* commit '66013410e88ae0014d4af305fbcc4993463095d1':
  Fix bad elf data handling.
diff --git a/src/dwarf/Gfind_proc_info-lsb.c b/src/dwarf/Gfind_proc_info-lsb.c
index f74b734..bc04cd1 100644
--- a/src/dwarf/Gfind_proc_info-lsb.c
+++ b/src/dwarf/Gfind_proc_info-lsb.c
@@ -112,6 +112,10 @@
   
   if (fread (&ehdr, sizeof (Elf_W (Ehdr)), 1, f) != 1)
     goto file_error;
+
+  /* Verify this is actually an elf file. */
+  if (memcmp(ehdr.e_ident, ELFMAG, SELFMAG) != 0)
+    goto file_error;
   
   shstrndx = ehdr.e_shstrndx;
   
@@ -120,7 +124,8 @@
 
   fseek (f, ehdr.e_shoff, SEEK_SET);
   sec_hdrs = calloc (ehdr.e_shnum, sizeof (Elf_W (Shdr)));
-  if (sec_hdrs == NULL || fread (sec_hdrs, sizeof (Elf_W (Shdr)), ehdr.e_shnum, f) != ehdr.e_shnum)
+  if (sec_hdrs == NULL || fread (sec_hdrs, sizeof (Elf_W (Shdr)), ehdr.e_shnum, f) != ehdr.e_shnum
+      || shstrndx >= ehdr.e_shnum)
     goto file_error;
 
   Debug (4, "loading string table of size %ld\n",