All of lore.kernel.org
 help / color / mirror / Atom feed
From: Glenn Washburn <development@efficientek.com>
To: grub-devel@gnu.org, Daniel Kiper <dkiper@net-space.pl>
Cc: Lukas Fink <lukas.fink1@gmail.com>,
	Glenn Washburn <development@efficientek.com>
Subject: [PATCH] commands/file: Fix null dereference in the knetbsd tests
Date: Sun,  5 Jan 2025 02:24:11 -0600	[thread overview]
Message-ID: <20250105082411.143880-1-development@efficientek.com> (raw)

From: Lukas Fink <lukas.fink1@gmail.com>

The pointer returned by grub_elf_file() is not checked to verify it is not
null before use. A null pointer may be returned when the given file does
not have a valid ELF header.

Fixes: https://savannah.gnu.org/bugs/?61960
Signed-off-by: Lukas Fink <lukas.fink1@gmail.com>
Signed-off-by: Glenn Washburn <development@efficientek.com>
---
 grub-core/commands/file.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/grub-core/commands/file.c b/grub-core/commands/file.c
index 7c13e976b505..19602d75786b 100644
--- a/grub-core/commands/file.c
+++ b/grub-core/commands/file.c
@@ -306,6 +306,8 @@ grub_cmd_file (grub_extcmd_context_t ctxt, int argc, char **args)
 
 	elf = grub_elf_file (file, file->name);
 
+	if (elf == NULL)
+	  break;
 	if (elf->ehdr.ehdr32.e_type != grub_cpu_to_le16_compile_time (ET_EXEC)
 	    || elf->ehdr.ehdr32.e_ident[EI_DATA] != ELFDATA2LSB)
 	  break;
-- 
2.34.1


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

             reply	other threads:[~2025-01-05  8:25 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-05  8:24 Glenn Washburn [this message]
2025-01-14 20:46 ` [PATCH] commands/file: Fix null dereference in the knetbsd tests Ross Philipson via Grub-devel
2025-02-20 16:11   ` 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=20250105082411.143880-1-development@efficientek.com \
    --to=development@efficientek.com \
    --cc=dkiper@net-space.pl \
    --cc=grub-devel@gnu.org \
    --cc=lukas.fink1@gmail.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.