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

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