Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1p2N2m-0007Si-9a for mharc-grub-devel@gnu.org; Mon, 05 Dec 2022 20:46:51 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p2N2d-0007SL-IB for grub-devel@gnu.org; Mon, 05 Dec 2022 20:46:39 -0500 Received: from cheddar.halon.org.uk ([93.93.131.118]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p2N2b-0003i3-KE for grub-devel@gnu.org; Mon, 05 Dec 2022 20:46:39 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=einval.com; s=default; h=Content-Transfer-Encoding:MIME-Version:Message-Id:Date:Subject: Cc:To:From:From:Reply-To:Subject:Content-Type:Content-ID:Content-Description: In-Reply-To:References:X-Debbugs-Cc; bh=SouxyLshEGEJW012t4k4RrMlgWmv7JgyCJhuyfE7c+k=; b=BZzHBzvesx8K2EPinW006BSFb8 yr4si/by6GV/T1WN0aNLh04mRYFOCGfEPKcKloVizauUW13yKh97iEJUPdtXhp/6odu4aYWDeybAq QjzrJckourj2WtMOtDhSPlBwiG4J3iahTa6zPjC1K3L+kpht0djfUvUB0OaVt+D/CIaCnKpYISL/8 bdag5pjmlgSZKudws596reqzefTGQ3xMTyV9TY9Z9JQ0UuhhONkiJCNCv0wLyZFLYqkpJbnmoc3KM SUoW5E1Q+WuwhsTwZcC9zfbIj5psgGC8BqcCk5uE87eVIsrHhq3qs74EP9QSCqqIdwrHmlxjvcVqQ b3NyfNLg==; Received: from bsmtp by cheddar.halon.org.uk with local-bsmtp (Exim 4.92) (envelope-from ) id 1p2N2A-0001rj-Eo; Tue, 06 Dec 2022 01:46:10 +0000 Received: from steve by tack.einval.org with local (Exim 4.94.2) (envelope-from ) id 1p2N1T-007QbX-2z; Tue, 06 Dec 2022 01:45:27 +0000 From: Steve McIntyre To: grub-devel@gnu.org Cc: Steve McIntyre Subject: [PATCH] kern/file: Fix error handling in grub_file_open() Date: Tue, 6 Dec 2022 01:45:11 +0000 Message-Id: <20221206014511.1768868-1-steve@einval.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=93.93.131.118; envelope-from=steve@einval.com; helo=cheddar.halon.org.uk X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Dec 2022 01:46:39 -0000 grub_file_open() calls grub_file_get_device_name(), but doesn't check the return. Instead, it checks if grub_errno is set. However, nothing initialises grub_errno here when grub_file_open() starts. This means that trying to open one file that doesn't exist and then trying to open another file that does will (incorrectly) also fail to open that second file. Let's fix that. Signed-off-by: Steve McIntyre --- grub-core/kern/file.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/grub-core/kern/file.c b/grub-core/kern/file.c index 8d48fd50d..668b149c3 100644 --- a/grub-core/kern/file.c +++ b/grub-core/kern/file.c @@ -66,6 +66,9 @@ grub_file_open (const char *name, enum grub_file_type type) const char *file_name; grub_file_filter_id_t filter; + /* Reset grub_errno before we start */ + grub_errno = GRUB_ERR_NONE; + device_name = grub_file_get_device_name (name); if (grub_errno) goto fail; -- 2.30.2