mirror of
https://src.fedoraproject.org/rpms/grub2.git
synced 2024-11-24 06:22:43 +00:00
Fix error handling in grub_file_open()
Signed-off-by: Robbie Harwood <rharwood@redhat.com>
This commit is contained in:
parent
9b063ec0c5
commit
85cfe6dd30
151 changed files with 200 additions and 162 deletions
34
0152-kern-file-Fix-error-handling-in-grub_file_open.patch
Normal file
34
0152-kern-file-Fix-error-handling-in-grub_file_open.patch
Normal file
|
@ -0,0 +1,34 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Steve McIntyre <steve@einval.com>
|
||||
Date: Tue, 6 Dec 2022 01:45:11 +0000
|
||||
Subject: [PATCH] kern/file: Fix error handling in grub_file_open()
|
||||
|
||||
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 <steve@einval.com>
|
||||
---
|
||||
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 58454458c4..5b58f45cfd 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;
|
|
@ -12,7 +12,7 @@ Signed-off-by: Renaud Métrich <rmetrich@redhat.com>
|
|||
1 file changed, 14 insertions(+)
|
||||
|
||||
diff --git a/grub-core/kern/file.c b/grub-core/kern/file.c
|
||||
index 58454458c4..e19aea3e51 100644
|
||||
index 5b58f45cfd..ec10e54fc0 100644
|
||||
--- a/grub-core/kern/file.c
|
||||
+++ b/grub-core/kern/file.c
|
||||
@@ -66,6 +66,8 @@ grub_file_open (const char *name, enum grub_file_type type)
|
||||
|
@ -21,10 +21,10 @@ index 58454458c4..e19aea3e51 100644
|
|||
|
||||
+ grub_dprintf ("file", "Opening `%s' ...\n", name);
|
||||
+
|
||||
device_name = grub_file_get_device_name (name);
|
||||
if (grub_errno)
|
||||
goto fail;
|
||||
@@ -128,6 +130,8 @@ grub_file_open (const char *name, enum grub_file_type type)
|
||||
/* Reset grub_errno before we start */
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
|
||||
@@ -131,6 +133,8 @@ grub_file_open (const char *name, enum grub_file_type type)
|
||||
if (!file)
|
||||
grub_file_close (last_file);
|
||||
|
||||
|
@ -33,7 +33,7 @@ index 58454458c4..e19aea3e51 100644
|
|||
return file;
|
||||
|
||||
fail:
|
||||
@@ -138,6 +142,8 @@ grub_file_open (const char *name, enum grub_file_type type)
|
||||
@@ -141,6 +145,8 @@ grub_file_open (const char *name, enum grub_file_type type)
|
||||
|
||||
grub_free (file);
|
||||
|
||||
|
@ -42,7 +42,7 @@ index 58454458c4..e19aea3e51 100644
|
|||
return 0;
|
||||
}
|
||||
|
||||
@@ -169,6 +175,7 @@ grub_file_read (grub_file_t file, void *buf, grub_size_t len)
|
||||
@@ -172,6 +178,7 @@ grub_file_read (grub_file_t file, void *buf, grub_size_t len)
|
||||
|
||||
if (len == 0)
|
||||
return 0;
|
||||
|
@ -50,7 +50,7 @@ index 58454458c4..e19aea3e51 100644
|
|||
read_hook = file->read_hook;
|
||||
read_hook_data = file->read_hook_data;
|
||||
if (!file->read_hook)
|
||||
@@ -189,11 +196,18 @@ grub_file_read (grub_file_t file, void *buf, grub_size_t len)
|
||||
@@ -192,11 +199,18 @@ grub_file_read (grub_file_t file, void *buf, grub_size_t len)
|
||||
grub_err_t
|
||||
grub_file_close (grub_file_t file)
|
||||
{
|
|
@ -18,10 +18,10 @@ Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
|
|||
1 file changed, 2 insertions(+)
|
||||
|
||||
diff --git a/grub-core/kern/file.c b/grub-core/kern/file.c
|
||||
index e19aea3e51..ed69fc0f0f 100644
|
||||
index ec10e54fc0..db938e099d 100644
|
||||
--- a/grub-core/kern/file.c
|
||||
+++ b/grub-core/kern/file.c
|
||||
@@ -81,6 +81,7 @@ grub_file_open (const char *name, enum grub_file_type type)
|
||||
@@ -84,6 +84,7 @@ grub_file_open (const char *name, enum grub_file_type type)
|
||||
|
||||
device = grub_device_open (device_name);
|
||||
grub_free (device_name);
|
||||
|
@ -29,7 +29,7 @@ index e19aea3e51..ed69fc0f0f 100644
|
|||
if (! device)
|
||||
goto fail;
|
||||
|
||||
@@ -135,6 +136,7 @@ grub_file_open (const char *name, enum grub_file_type type)
|
||||
@@ -138,6 +139,7 @@ grub_file_open (const char *name, enum grub_file_type type)
|
||||
return file;
|
||||
|
||||
fail:
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue