dcavalca / rpms / grub2

Forked from rpms/grub2 3 years ago
Clone

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

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