From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 116163 invoked by alias); 5 Jun 2018 21:36:50 -0000 Mailing-List: contact elfutils-devel-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Post: List-Help: List-Subscribe: Sender: elfutils-devel-owner@sourceware.org Received: (qmail 114624 invoked by uid 89); 5 Jun 2018 21:36:47 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Checked: by ClamAV 0.99.4 on sourceware.org X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=Close, highly X-Spam-Status: No, score=-26.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on sourceware.org X-Spam-Level: X-HELO: gnu.wildebeest.org Received: from wildebeest.demon.nl (HELO gnu.wildebeest.org) (212.238.236.112) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 05 Jun 2018 21:36:46 +0000 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 68C8B307C548; Tue, 5 Jun 2018 23:36:44 +0200 (CEST) Received: by tarox.wildebeest.org (Postfix, from userid 1000) id 532BA44263C1; Tue, 5 Jun 2018 23:36:44 +0200 (CEST) From: Mark Wielaard To: elfutils-devel@sourceware.org Cc: Mark Wielaard Subject: [PATCH] libdw: Explicitly check we could decode diridx in dwarf_getsrclines. Date: Tue, 05 Jun 2018 21:36:00 -0000 Message-Id: <1528234602-32214-1-git-send-email-mark@klomp.org> X-Mailer: git-send-email 1.8.3.1 X-Spam-Flag: NO X-IsSubscribed: yes X-SW-Source: 2018-q2/txt/msg00157.txt.bz2 It is highly unlikely dwarf_formudata fails because we setup the attribute ourselves, but better to explicitly mark diridx as bad if it does. Signed-off-by: Mark Wielaard --- libdw/ChangeLog | 5 +++++ libdw/dwarf_getsrclines.c | 5 +++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/libdw/ChangeLog b/libdw/ChangeLog index 661fa9d..21adeb7 100644 --- a/libdw/ChangeLog +++ b/libdw/ChangeLog @@ -1,5 +1,10 @@ 2018-06-05 Mark Wielaard + * dwarf_getsrclines.c (read_srclines): Explicitly set diridx to -1 + in case dwarf_formudata fails. + +2018-06-05 Mark Wielaard + * dwarf_getaranges (dwarf_getaranges): Free new_arange if __libdw_findcu fails. diff --git a/libdw/dwarf_getsrclines.c b/libdw/dwarf_getsrclines.c index 0c2efaa..07baebc 100644 --- a/libdw/dwarf_getsrclines.c +++ b/libdw/dwarf_getsrclines.c @@ -566,7 +566,7 @@ read_srclines (Dwarf *dbg, for (unsigned int n = 0; n < nfiles; n++) { const char *fname = NULL; - Dwarf_Word diridx = -1; + Dwarf_Word diridx = (Dwarf_Word) -1; for (unsigned char m = 0; m < nforms; m++) { if (m == form_path) @@ -581,7 +581,8 @@ read_srclines (Dwarf *dbg, attr.code = DW_AT_decl_file; /* Close enough. */ attr.form = forms[m]; attr.valp = (void *) linep; - dwarf_formudata (&attr, &diridx); + if (dwarf_formudata (&attr, &diridx) != 0) + diridx = (Dwarf_Word) -1; } size_t len = __libdw_form_val_len (&fake_cu, forms[m], linep); -- 1.8.3.1