From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id D16A2159C9B for ; Fri, 9 Aug 2024 10:06:24 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 15FE82BC0A5; Fri, 9 Aug 2024 10:06:24 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id E44422BC0A1 for ; Fri, 9 Aug 2024 10:06:23 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 0CD613430B6 for ; Fri, 9 Aug 2024 10:06:23 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 9923A1B9A for ; Fri, 9 Aug 2024 10:06:21 +0000 (UTC) From: "Sam James" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Sam James" Message-ID: <1723197976.d1d12246b7c5df3e20b062e536da9b4e639a4a66.sam@gentoo> Subject: [gentoo-commits] proj/pax-utils:master commit in: / X-VCS-Repository: proj/pax-utils X-VCS-Files: dumpelf.c X-VCS-Directories: / X-VCS-Committer: sam X-VCS-Committer-Name: Sam James X-VCS-Revision: d1d12246b7c5df3e20b062e536da9b4e639a4a66 X-VCS-Branch: master Date: Fri, 9 Aug 2024 10:06:21 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: eb38787b-6885-477d-95b9-e62a49dc2143 X-Archives-Hash: f77bff8d46bd0d967cbae678f5f9a15a commit: d1d12246b7c5df3e20b062e536da9b4e639a4a66 Author: Mike Frysinger gentoo org> AuthorDate: Fri Jan 26 03:46:42 2024 +0000 Commit: Sam James gentoo org> CommitDate: Fri Aug 9 10:06:16 2024 +0000 URL: https://gitweb.gentoo.org/proj/pax-utils.git/commit/?id=d1d12246 dumpelf: check dyn pointer before DT_NULL check too We were checking the pointer before dumping it, but missed the DT_NULL check in the overall while loop. Signed-off-by: Mike Frysinger gentoo.org> (cherry picked from commit 7b37c40d0409d79a925b71135e9de96343096ce8) Signed-off-by: Sam James gentoo.org> dumpelf.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/dumpelf.c b/dumpelf.c index 0afb6c7..6ce8403 100644 --- a/dumpelf.c +++ b/dumpelf.c @@ -125,13 +125,17 @@ static void dumpelf(const elfobj *elf, size_t file_cnt) if (elf->elf_class == ELFCLASS ## B) { \ const Elf ## B ## _Phdr *phdr = phdr_dynamic_void; \ const Elf ## B ## _Dyn *dyn = elf->vdata + EGET(phdr->p_offset); \ + if ((void *)dyn >= elf->data_end - sizeof(*dyn)) { \ + printf(" /* invalid dynamic tags ! */ "); \ + goto break_out_dyn; \ + } \ i = 0; \ do { \ + dump_dyn(elf, dyn++, i++); \ if ((void *)dyn >= elf->data_end - sizeof(*dyn)) { \ printf(" /* invalid dynamic tags ! */ "); \ break; \ } \ - dump_dyn(elf, dyn++, i++); \ } while (EGET(dyn->d_tag) != DT_NULL); \ } DUMP_DYNS(32) @@ -139,6 +143,7 @@ static void dumpelf(const elfobj *elf, size_t file_cnt) } else { printf(" /* no dynamic tags ! */ "); } + break_out_dyn: printf("};\n"); }