From patchwork Sat Sep 7 22:00:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Wielaard X-Patchwork-Id: 97310 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6A6A4385DDC7 for ; Sat, 7 Sep 2024 22:00:19 +0000 (GMT) X-Original-To: elfutils-devel@sourceware.org Delivered-To: elfutils-devel@sourceware.org Received: from gnu.wildebeest.org (gnu.wildebeest.org [45.83.234.184]) by sourceware.org (Postfix) with ESMTPS id D90873858C33 for ; Sat, 7 Sep 2024 22:00:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D90873858C33 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=klomp.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=klomp.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org D90873858C33 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=45.83.234.184 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1725746410; cv=none; b=EOYI8PtvXOSazn6H4jtdrxhY2rNnyxz1ANJWhJgeA1xYXPwOF6pgZqMVweG2vZtu17yqfESEPLV5Fy2QX/sdEwJChECol/MgTt4Ouy6loHakO1wJjQ4FfxbGjmWf5Eu/DUA57P63IC/MP/N+XlUxDX/LHYGFXCj1MFk8bhmGhyY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1725746410; c=relaxed/simple; bh=fOI087Yp1meVs2HHllUEJgfW97mZzV9QZ63qjoEa0bY=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=lciZ/K5z7U/PlE1SDH/7wRfTIhv94jYRugT3eX06/nSU6mvOE8TlWQd3TRLFyHsxq+CGeg9KN7Cs/Q9+eeOyg5zQ0pvQuZ76do8FREJ/6nl9QO9YtOOOS9NWAIUE+XDVvUwEFWEyx74/hRx8xeEm8It63WG+Bx60hoYFLo8FhFo= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from mwielaar-thinkpadp1gen3.rmtnl.csb (deer0x08.wildebeest.org [172.31.17.138]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by gnu.wildebeest.org (Postfix) with ESMTPSA id A5C3A30D0622; Sun, 8 Sep 2024 00:00:07 +0200 (CEST) Received: by mwielaar-thinkpadp1gen3.rmtnl.csb (Postfix, from userid 10916) id 6246740C3B4; Sun, 8 Sep 2024 00:00:07 +0200 (CEST) From: Mark Wielaard To: elfutils-devel@sourceware.org Cc: Mark Wielaard Subject: [PATCH] readelf: Allow .gdb_index const table to be empty Date: Sun, 8 Sep 2024 00:00:05 +0200 Message-ID: <20240907220005.447083-1-mark@klomp.org> X-Mailer: git-send-email 2.46.0 MIME-Version: 1.0 X-Spam-Status: No, score=-8.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: elfutils-devel@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Elfutils-devel mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: elfutils-devel-bounces~patchwork=sourceware.org@sourceware.org The .gdb_index const table can be empty, if no symbol table entry refers to a name or CU. Which technically means the symbol table is empty or has only zero members. * src/readelf.c (print_gdb_index_section): Check const_off is not past the end of the data section, it can be at the end. Signed-off-by: Mark Wielaard --- src/readelf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/readelf.c b/src/readelf.c index 8d96443daa83..21cacd7b6c06 100644 --- a/src/readelf.c +++ b/src/readelf.c @@ -11679,7 +11679,7 @@ print_gdb_index_section (Dwfl_Module *dwflmod, Ebl *ebl, } const unsigned char *const_start = data->d_buf + const_off; - if (const_off >= data->d_size) + if (const_off > data->d_size) goto invalid_data; const unsigned char *shortcut_start = NULL;