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 D6829389041C for ; Fri, 22 Jan 2021 12:40:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org D6829389041C Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=klomp.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mark@klomp.org Received: from tarox.wildebeest.org (tarox.wildebeest.org [172.31.17.39]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by gnu.wildebeest.org (Postfix) with ESMTPSA id 5019F3000608; Fri, 22 Jan 2021 13:40:54 +0100 (CET) Received: by tarox.wildebeest.org (Postfix, from userid 1000) id 04CEF401656F; Fri, 22 Jan 2021 13:40:54 +0100 (CET) From: Mark Wielaard To: dwz@sourceware.org Cc: Mark Wielaard Subject: [PATCH] Don't crash on DWARF5 .debug_line table with zero files. Date: Fri, 22 Jan 2021 13:40:47 +0100 Message-Id: <20210122124047.20503-1-mark@klomp.org> X-Mailer: git-send-email 2.18.4 X-Spam-Status: No, score=-11.5 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.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: dwz@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Dwz mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Jan 2021 12:40:59 -0000 Not having any files in a DWARF5 .debug_line table is odd, but not technically invalid. Normally there should be a zero file entry that is equal to the compile unit main file (there is no such zero entry for early DWARF versions and we handle no file entries fine in that case). https://bugzilla.redhat.com/show_bug.cgi?id=1919243 --- dwz.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dwz.c b/dwz.c index 53b9548..28f0c4d 100644 --- a/dwz.c +++ b/dwz.c @@ -1839,7 +1839,8 @@ read_debug_line (DSO *dso, dw_cu_ref cu, uint32_t off) } nfiles = read_uleb128 (ptr); - nfiles--; /* We will skip the first (zero) entry. */ + if (nfiles > 0) + nfiles--; /* We will skip the first (zero) entry. */ } cu->cu_nfiles = nfiles; -- 2.18.4