]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
strip: Always check gelf_update results.
authorMark Wielaard <mark@klomp.org>
Fri, 18 Jun 2021 13:06:32 +0000 (15:06 +0200)
committerMark Wielaard <mark@klomp.org>
Fri, 2 Jul 2021 22:25:18 +0000 (00:25 +0200)
Signed-off-by: Mark Wielaard <mark@klomp.org>
src/ChangeLog
src/strip.c

index 698b3c77c8d0ebebc18ed9751a1cb3f251db9336..9d4ce31d2547b1630109db28fa5fb02a8cb1aa30 100644 (file)
@@ -1,3 +1,8 @@
+2021-06-18  Mark Wielaard  <mark@klomp.org>
+
+       * strip.c (remove_debug_relocations): Check gelf_update results.
+       (update_section_size): Likewise.
+
 2021-06-06  Sergei Trofimovich  <slyfox@gentoo.org>
 
        * elflint.c (buffer_left): Mark as 'static' to avoid external linkage
index 70fc8c03e9310e4636af845caa7c6217fcebf5ce..961b9db58fd403e627888cc47752768075cc1d57 100644 (file)
@@ -705,17 +705,21 @@ remove_debug_relocations (Ebl *ebl, Elf *elf, GElf_Ehdr *ehdr,
 relocate_failed:
              if (relidx != next)
                {
+                 int updated;
                  if (is_rela)
-                   gelf_update_rela (reldata, next, rel_p);
+                   updated = gelf_update_rela (reldata, next, rel_p);
                  else
-                   gelf_update_rel (reldata, next, rel_p);
+                   updated = gelf_update_rel (reldata, next, rel_p);
+                 if (updated == 0)
+                   INTERNAL_ERROR (fname);
                }
              ++next;
            }
 
          nrels = next;
          shdr->sh_size = reldata->d_size = nrels * shdr->sh_entsize;
-         gelf_update_shdr (scn, shdr);
+         if (gelf_update_shdr (scn, shdr) == 0)
+           INTERNAL_ERROR (fname);
 
          if (is_gnu_compressed)
            {
@@ -952,7 +956,8 @@ update_section_size (Elf_Scn *scn,
   GElf_Shdr shdr_mem;
   GElf_Shdr *shdr = gelf_getshdr (scn, &shdr_mem);
   shdr->sh_size = newdata->d_size;
-  (void) gelf_update_shdr (scn, shdr);
+  if (gelf_update_shdr (scn, shdr) == 0)
+    INTERNAL_ERROR (fname);
   if (debugelf != NULL)
     {
       /* libelf will use d_size to set sh_size.  */