From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from zimbra2.kalray.eu ([92.103.151.219]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jjdqy-00069c-EE for barebox@lists.infradead.org; Fri, 12 Jun 2020 07:11:53 +0000 From: Clement Leger Date: Fri, 12 Jun 2020 09:10:32 +0200 Message-Id: <20200612071036.27864-5-cleger@kalray.eu> In-Reply-To: <20200612071036.27864-1-cleger@kalray.eu> References: <20200612071036.27864-1-cleger@kalray.eu> List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "barebox" Errors-To: barebox-bounces+u.kleine-koenig=pengutronix.de@lists.infradead.org Subject: [PATCH v6 4/8] common: elf: check number of elf program headers To: Sascha Hauer , barebox@lists.infradead.org Cc: Clement Leger , Oleksij Rempel An elf file without program headers should not be loaded. Add a check for such cases. Signed-off-by: Clement Leger --- common/elf.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/common/elf.c b/common/elf.c index 0e92661e1..bd97858c8 100644 --- a/common/elf.c +++ b/common/elf.c @@ -119,6 +119,11 @@ static int elf_check_image(struct elf_image *elf) return -ENOEXEC; } + if (!elf_hdr_e_phnum(elf, elf->buf)) { + pr_err("No phdr found.\n"); + return -ENOEXEC; + } + return 0; } -- 2.17.1 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox