From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gnu.wildebeest.org (wildebeest.demon.nl [212.238.236.112]) by sourceware.org (Postfix) with ESMTPS id 45B4F3860C32 for ; Fri, 18 Jun 2021 13:06:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 45B4F3860C32 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=klomp.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=klomp.org Received: from tarox.wildebeest.org (83-87-18-245.cable.dynamic.v4.ziggo.nl [83.87.18.245]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by gnu.wildebeest.org (Postfix) with ESMTPSA id 43442300159D; Fri, 18 Jun 2021 15:06:34 +0200 (CEST) Received: by tarox.wildebeest.org (Postfix, from userid 1000) id EB13640350D6; Fri, 18 Jun 2021 15:06:33 +0200 (CEST) From: Mark Wielaard To: elfutils-devel@sourceware.org Cc: Mark Wielaard Subject: [PATCH] strip: Always check gelf_update results. Date: Fri, 18 Jun 2021 15:06:32 +0200 Message-Id: <20210618130632.22788-1-mark@klomp.org> X-Mailer: git-send-email 2.18.4 X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: elfutils-devel@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Elfutils-devel mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Jun 2021 13:06:36 -0000 Signed-off-by: Mark Wielaard --- src/ChangeLog | 5 +++++ src/strip.c | 13 +++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 698b3c77..9d4ce31d 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2021-06-18 Mark Wielaard + + * strip.c (remove_debug_relocations): Check gelf_update results. + (update_section_size): Likewise. + 2021-06-06 Sergei Trofimovich * elflint.c (buffer_left): Mark as 'static' to avoid external linkage diff --git a/src/strip.c b/src/strip.c index 70fc8c03..961b9db5 100644 --- a/src/strip.c +++ b/src/strip.c @@ -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. */ -- 2.18.4