Skip to contentSkip to conversation

MULTIBOOT: Fix handling of errors in broken aout-kludge

PATCH In review Vladimir Serbinenko 2 participants 2 messages May 17, 2024 – Jun 3, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 MULTIBOOT: Fix handling of errors in broken aout-kludge

Current code in some codepaths neither discards nor reports errors. Properly surface the error

While on it split 2 cases of unrelated variables both named err.

---
 grub-core/loader/i386/multiboot_mbi.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
grub-core/loader/i386/multiboot_mbi.c +6 -3
index fae5d6fb8..bdaf67ad0 100644
@@ -69,7 +69,6 @@ static grub_err_t
 load_kernel (grub_file_t file, const char *filename,
 	     char *buffer, struct multiboot_header *header)
 {
-  grub_err_t err;
   mbi_load_data_t mld;
 
   mld.file = file;
@@ -81,12 +80,15 @@ load_kernel (grub_file_t file, const char *filename,
 
   if (grub_multiboot_quirks & GRUB_MULTIBOOT_QUIRK_BAD_KLUDGE)
     {
-      err = grub_multiboot_load_elf (&mld);
+      grub_err_t err = grub_multiboot_load_elf (&mld);
+
       if (err == GRUB_ERR_NONE) {
 	return GRUB_ERR_NONE;
       }
       if (err == GRUB_ERR_UNKNOWN_OS && (header->flags & MULTIBOOT_AOUT_KLUDGE))
-	grub_errno = GRUB_ERR_NONE;
+	grub_errno = err = GRUB_ERR_NONE;
+      if (err != GRUB_ERR_NONE)
+	return err;
     }
   if (header->flags & MULTIBOOT_AOUT_KLUDGE)
     {
@@ -97,6 +99,7 @@ load_kernel (grub_file_t file, const char *filename,
       grub_size_t code_size;
       void *source;
       grub_relocator_chunk_t ch;
+      grub_err_t err;
 
       if (header->bss_end_addr)
 	code_size = (header->bss_end_addr - header->load_addr);
Signature · 7 lines
2.39.2


_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Vladimir Serbinenko

Current code in some codepaths neither discards nor reports errors. Properly surface the error

While on it split 2 cases of unrelated variables both named err.

Daniel

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel