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 9B3C9386F447 for ; Tue, 16 Jun 2020 22:26:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 9B3C9386F447 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 62A74317FC0F; Wed, 17 Jun 2020 00:25:58 +0200 (CEST) Received: by tarox.wildebeest.org (Postfix, from userid 1000) id 1B4D74024128; Wed, 17 Jun 2020 00:25:58 +0200 (CEST) From: Mark Wielaard To: elfutils-devel@sourceware.org Cc: Mark Wielaard Subject: [PATCH 04/10] libdwfl: When we find a compressed image, use that, don't search for others Date: Wed, 17 Jun 2020 00:25:33 +0200 Message-Id: <20200616222539.29109-4-mark@klomp.org> X-Mailer: git-send-email 2.18.4 In-Reply-To: <20200616222539.29109-1-mark@klomp.org> References: <20200616222539.29109-1-mark@klomp.org> X-Spam-Status: No, score=-12.4 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: elfutils-devel@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Elfutils-devel mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 16 Jun 2020 22:26:02 -0000 We try to find a compressed vmlinux image ending with either .gz, bz2 or xz. Stop searching if we find one. Otherwise we will leak a file descriptor for an earlier one we opened. Signed-off-by: Mark Wielaard --- libdwfl/ChangeLog | 5 +++++ libdwfl/linux-kernel-modules.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog index 4f1ec9da..44b3ece7 100644 --- a/libdwfl/ChangeLog +++ b/libdwfl/ChangeLog @@ -1,3 +1,8 @@ +2020-06-16 Mark Wielaard + + * linux-kernel-modules.c (try_kernel_name): Don't try other + compressed kernels if we already found an compressed image. + 2020-05-09 Mark Wielaard * find-debuginfo.c (dwfl_standard_find_debuginfo): Return failure diff --git a/libdwfl/linux-kernel-modules.c b/libdwfl/linux-kernel-modules.c index 0434f1e5..84a05f28 100644 --- a/libdwfl/linux-kernel-modules.c +++ b/libdwfl/linux-kernel-modules.c @@ -128,7 +128,7 @@ try_kernel_name (Dwfl *dwfl, char **fname, bool try_debug) if (fd < 0) for (size_t i = 0; - i < sizeof vmlinux_suffixes / sizeof vmlinux_suffixes[0]; + i < sizeof vmlinux_suffixes / sizeof vmlinux_suffixes[0] && fd < 0; ++i) { char *zname; -- 2.18.4