dcavalca / rpms / grub2

Forked from rpms/grub2 3 years ago
Clone

Blame SOURCES/0428-commands-ls-Require-device_name-is-not-NULL-before-p.patch

468bd4
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
468bd4
From: Daniel Axtens <dja@axtens.net>
468bd4
Date: Mon, 11 Jan 2021 16:57:37 +1100
468bd4
Subject: [PATCH] commands/ls: Require device_name is not NULL before printing
468bd4
468bd4
This can be triggered with:
468bd4
  ls -l (0 0*)
468bd4
and causes a NULL deref in grub_normal_print_device_info().
468bd4
468bd4
I'm not sure if there's any implication with the IEEE 1275 platform.
468bd4
468bd4
Signed-off-by: Daniel Axtens <dja@axtens.net>
468bd4
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
468bd4
---
468bd4
 grub-core/commands/ls.c | 2 +-
468bd4
 1 file changed, 1 insertion(+), 1 deletion(-)
468bd4
468bd4
diff --git a/grub-core/commands/ls.c b/grub-core/commands/ls.c
468bd4
index 2cdb2acc552..d4dcffd3168 100644
468bd4
--- a/grub-core/commands/ls.c
468bd4
+++ b/grub-core/commands/ls.c
468bd4
@@ -196,7 +196,7 @@ grub_ls_list_files (char *dirname, int longlist, int all, int human)
468bd4
       goto fail;
468bd4
     }
468bd4
 
468bd4
-  if (! *path)
468bd4
+  if (! *path && device_name)
468bd4
     {
468bd4
       if (grub_errno == GRUB_ERR_UNKNOWN_FS)
468bd4
 	grub_errno = GRUB_ERR_NONE;