grub-devel.gnu.org archive mirror
 help / color / mirror / Atom feed
From: "Vladimir 'phcoder' Serbinenko" <phcoder@gmail.com>
To: The development of GRUB 2 <grub-devel@gnu.org>
Subject: [PATCH] MULTIBOOT: Fix handling of errors in broken aout-kludge
Date: Tue, 20 Feb 2024 13:14:42 +0300	[thread overview]
Message-ID: <CAEaD8JMZ2RgZfWS-o7LbttYXsu9wtU=kXEQDboWm9qywXMYFBA@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 42 bytes --]

-- 
Regards
Vladimir 'phcoder' Serbinenko

[-- Attachment #2: 0001-MULTIBOOT-Fix-handling-of-errors-in-broken-aout-klud.patch --]
[-- Type: application/octet-stream, Size: 1714 bytes --]

From 571f610d599d022d82e5e94c0cf5d596289ba66a Mon Sep 17 00:00:00 2001
From: Vladimir Serbinenko <phcoder@gmail.com>
Date: Sat, 27 Jan 2024 01:46:56 +0300
Subject: [PATCH] MULTIBOOT: Fix handling of errors in broken aout-kludge

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

Signed-off-by: Vladimir Serbinenko <phcoder@gmail.com>
---
 grub-core/loader/i386/multiboot_mbi.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/grub-core/loader/i386/multiboot_mbi.c b/grub-core/loader/i386/multiboot_mbi.c
index fae5d6fb8..ce1381f05 100644
--- a/grub-core/loader/i386/multiboot_mbi.c
+++ b/grub-core/loader/i386/multiboot_mbi.c
@@ -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)
     {
+      grub_err_t err;
       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)
+	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);
-- 
2.39.2


[-- Attachment #3: Type: text/plain, Size: 141 bytes --]

_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel

             reply	other threads:[~2024-02-20 10:15 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-20 10:14 Vladimir 'phcoder' Serbinenko [this message]
2024-02-22 14:39 ` [PATCH] MULTIBOOT: Fix handling of errors in broken aout-kludge Daniel Kiper

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAEaD8JMZ2RgZfWS-o7LbttYXsu9wtU=kXEQDboWm9qywXMYFBA@mail.gmail.com' \
    --to=phcoder@gmail.com \
    --cc=grub-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).