From: Roland McGrath Date: Fri, 4 Jun 2010 09:26:30 +0000 (-0700) Subject: unstrip: Bail early on bogus invocation with reversed arguments. X-Git-Tag: elfutils-0.148~29 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3b1b651d89d14b948a7e2436efdbe89d9bf691c0;p=thirdparty%2Felfutils.git unstrip: Bail early on bogus invocation with reversed arguments. --- diff --git a/src/ChangeLog b/src/ChangeLog index 58fc5b85f..90c78cb5d 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2010-06-04 Roland McGrath + + * 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 * readelf.c (dwarf_form_string): Handle DWARF 4 forms. diff --git a/src/unstrip.c b/src/unstrip.c index 0984e6bc2..755c42a32 100644 --- a/src/unstrip.c +++ b/src/unstrip.c @@ -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;