From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 39B141384B4 for ; Sat, 12 Dec 2015 22:45:51 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id A60E8E087E; Sat, 12 Dec 2015 22:45:48 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 19F5CE088D for ; Sat, 12 Dec 2015 22:45:47 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 0F5FD3403C1 for ; Sat, 12 Dec 2015 22:45:47 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 854DECAF for ; Sat, 12 Dec 2015 22:45:45 +0000 (UTC) From: "Mike Frysinger" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Mike Frysinger" Message-ID: <1449955797.61ee81b90f679cc47bcb0e237e9373a4e0f4e04b.vapier@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: vapier X-VCS-Committer-Name: Mike Frysinger X-VCS-Revision: 61ee81b90f679cc47bcb0e237e9373a4e0f4e04b X-VCS-Branch: master Date: Sat, 12 Dec 2015 22:45:45 +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-Archives-Salt: a1ad243a-f5f3-4118-a4bd-829ef645d230 X-Archives-Hash: 83d6bf11d00d1a38f8b88abb720bedbe commit: 61ee81b90f679cc47bcb0e237e9373a4e0f4e04b Author: Mike Frysinger gentoo org> AuthorDate: Sat Dec 12 21:29:57 2015 +0000 Commit: Mike Frysinger gentoo org> CommitDate: Sat Dec 12 21:29:57 2015 +0000 URL: https://gitweb.gentoo.org/proj/pax-utils.git/commit/?id=61ee81b9 dumpelf: handle corrupt section headers URL: https://bugs.gentoo.org/567954 Reported-by: Brian Carpenter gmail.com> dumpelf.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/dumpelf.c b/dumpelf.c index 0f15382..fe0001b 100644 --- a/dumpelf.c +++ b/dumpelf.c @@ -102,9 +102,19 @@ static void dumpelf(const char *filename, long file_cnt) Elf ## B ## _Ehdr *ehdr = EHDR ## B (elf->ehdr); \ Elf ## B ## _Shdr *shdr = SHDR ## B (elf->shdr); \ uint16_t shstrndx = EGET(ehdr->e_shstrndx); \ - Elf ## B ## _Off offset = EGET(shdr[shstrndx].sh_offset); \ + Elf ## B ## _Shdr *strtbl = shdr + shstrndx; \ + Elf ## B ## _Off offset; \ uint16_t shnum = EGET(ehdr->e_shnum); \ + if (shstrndx >= shnum || !VALID_SHDR(elf, strtbl)) { \ + printf(" /* corrupt section header strings table ! */ "); \ + goto break_out_shdr; \ + } \ + offset = EGET(strtbl->sh_offset); \ for (i = 0; i < shnum; ++i, ++shdr) \ + if (!VALID_SHDR(elf, shdr)) { \ + printf(" /* corrupt section headers ! */ "); \ + break; \ + } \ dump_shdr(elf, shdr, i, elf->vdata + offset + EGET(shdr->sh_name)); \ } DUMP_SHDRS(32) @@ -112,6 +122,7 @@ static void dumpelf(const char *filename, long file_cnt) } else { printf(" /* no section headers ! */ "); } + break_out_shdr: printf("},\n"); /* finish the namespace struct and start the abitrary ones */