]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
dwarflint: More thorough validation of ELF sections
authorPetr Machata <pmachata@redhat.com>
Thu, 17 Mar 2011 12:17:35 +0000 (13:17 +0100)
committerPetr Machata <pmachata@redhat.com>
Thu, 17 Mar 2011 12:17:35 +0000 (13:17 +0100)
dwarflint/sections.cc

index d5736c4bedb154e5001c13e377b3c5e7bb6483dd..4a8f6401efd530b6129aa0163a9d39d78d1c0afb 100644 (file)
@@ -250,12 +250,7 @@ namespace
     REALLOC (file, sec);
     file->sec[file->size++].id = sec_invalid;
 
-    bool check_rel = true;
-
-    /* Try to obtain .shstrtab, which we will need in following.  If
-       we fail, elf is broken.  */
-    Elf_Scn *shstrscn = elf_getscn (elf, file->ehdr.e_shstrndx);
-    if (shstrscn == NULL || elf_rawdata (shstrscn, NULL) == NULL)
+    if (false)
       {
       invalid_elf:
        wr_error () << "Broken ELF: " << elf_errmsg (-1) << "."
@@ -263,6 +258,11 @@ namespace
        goto close_and_out;
       }
 
+    /* Check that the ELF file is sound.  */
+    for (Elf_Scn *scn = NULL; (scn = elf_nextscn (elf, scn)); )
+      if (elf_rawdata (scn, NULL) == NULL)
+       goto invalid_elf;
+
     for (Elf_Scn *scn = NULL; (scn = elf_nextscn (elf, scn)); )
       {
        REALLOC (file, sec);
@@ -366,7 +366,7 @@ namespace
       if (it->second.secndx != 0)
        file->debugsec[it->second.id] = file->sec + it->second.secndx;
 
-    if (check_rel)
+    if (true)
       {
        Elf_Data *reloc_symdata = NULL;
        if (reloc_symtab != NULL)