Blame SOURCES/0149-kern-file-Fix-error-handling-in-grub_file_open.patch

fd0330
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
fd0330
From: Steve McIntyre <steve@einval.com>
fd0330
Date: Tue, 6 Dec 2022 01:45:11 +0000
fd0330
Subject: [PATCH] kern/file: Fix error handling in grub_file_open()
fd0330
fd0330
grub_file_open() calls grub_file_get_device_name(), but doesn't check
fd0330
the return. Instead, it checks if grub_errno is set.
fd0330
fd0330
However, nothing initialises grub_errno here when grub_file_open()
fd0330
starts. This means that trying to open one file that doesn't exist and
fd0330
then trying to open another file that does will (incorrectly) also
fd0330
fail to open that second file.
fd0330
fd0330
Let's fix that.
fd0330
fd0330
Signed-off-by: Steve McIntyre <steve@einval.com>
fd0330
---
fd0330
 grub-core/kern/file.c | 3 +++
fd0330
 1 file changed, 3 insertions(+)
fd0330
fd0330
diff --git a/grub-core/kern/file.c b/grub-core/kern/file.c
fd0330
index 58454458c4..5b58f45cfd 100644
fd0330
--- a/grub-core/kern/file.c
fd0330
+++ b/grub-core/kern/file.c
fd0330
@@ -66,6 +66,9 @@ grub_file_open (const char *name, enum grub_file_type type)
fd0330
   const char *file_name;
fd0330
   grub_file_filter_id_t filter;
fd0330
 
fd0330
+  /* Reset grub_errno before we start */
fd0330
+  grub_errno = GRUB_ERR_NONE;
fd0330
+
fd0330
   device_name = grub_file_get_device_name (name);
fd0330
   if (grub_errno)
fd0330
     goto fail;