From 3b1b651d89d14b948a7e2436efdbe89d9bf691c0 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Fri, 4 Jun 2010 02:26:30 -0700 Subject: [PATCH] unstrip: Bail early on bogus invocation with reversed arguments. --- src/ChangeLog | 5 +++++ src/unstrip.c | 4 ++++ 2 files changed, 9 insertions(+) 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; -- 2.47.2