]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
unstrip: Bail early on bogus invocation with reversed arguments.
authorRoland McGrath <roland@redhat.com>
Fri, 4 Jun 2010 09:26:30 +0000 (02:26 -0700)
committerRoland McGrath <roland@redhat.com>
Mon, 14 Jun 2010 19:52:09 +0000 (12:52 -0700)
src/ChangeLog
src/unstrip.c

index 58fc5b85fad246ebbf0c1556414f4b535f933bed..90c78cb5d49168686d0debd720f850d5956c93c7 100644 (file)
@@ -1,3 +1,8 @@
+2010-06-04  Roland McGrath  <roland@redhat.com>
+
+       * unstrip.c (copy_elided_sections): Bail if stripped file has more
+       sections than unstripped file, rather than getting confused later.
+
 2010-06-01  Roland McGrath  <roland@redhat.com>
 
        * readelf.c (dwarf_form_string): Handle DWARF 4 forms.
index 0984e6bc2744c17b51d146fdc422058b03532dc6..755c42a32eb89f1f4f72fece1f1e943983002cf8 100644 (file)
@@ -1234,6 +1234,10 @@ copy_elided_sections (Elf *unstripped, Elf *stripped,
   ELF_CHECK (elf_getshdrnum (stripped, &stripped_shnum) == 0,
             _("cannot get section count: %s"));
 
+  if (unlikely (stripped_shnum > unstripped_shnum))
+    error (EXIT_FAILURE, 0, _("\
+more sections in stripped file than debug file -- arguments reversed?"));
+
   /* Cache the stripped file's section details.  */
   struct section sections[stripped_shnum - 1];
   Elf_Scn *scn = NULL;