]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
unstrip: exit early if there are no sections in the stripped file
authorMark Wielaard <mark@klomp.org>
Sun, 1 Jun 2025 23:35:16 +0000 (01:35 +0200)
committerMark Wielaard <mark@klomp.org>
Sun, 1 Jun 2025 23:35:16 +0000 (01:35 +0200)
If there is only section zero that shouldn't count. Then we would
still try to work on an empty set of sections and give an obscure
error later.

    * src/unstrip.c (copy_elided_sections): Check stripped_shnum <= 1.

Signed-off-by: Mark Wielaard <mark@klomp.org>
src/unstrip.c

index 0ae76f77e9ae86aefa91ce6d991587a298a58213..81c5496f43a0214ff722c4f43231099a169a871d 100644 (file)
@@ -1447,7 +1447,7 @@ copy_elided_sections (Elf *unstripped, Elf *stripped,
     error_exit (0, _("\
 more sections in stripped file than debug file -- arguments reversed?"));
 
-  if (unlikely (stripped_shnum == 0))
+  if (unlikely (stripped_shnum <= 1))
     error_exit (0, _("no sections in stripped file"));
 
   /* Used as sanity check for allocated section offset, if the section