1From 6afbe6063c95b827372f9ec310c9fc7461311eb1 Mon Sep 17 00:00:00 2001
2From: Daniel Axtens <dja@axtens.net>
3Date: Mon, 11 Jan 2021 16:57:37 +1100
4Subject: [PATCH] commands/ls: Require device_name is not NULL before printing
5
6This can be triggered with:
7  ls -l (0 0*)
8and causes a NULL deref in grub_normal_print_device_info().
9
10I'm not sure if there's any implication with the IEEE 1275 platform.
11
12Signed-off-by: Daniel Axtens <dja@axtens.net>
13Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
14Signed-off-by: Stefan Sørensen <stefan.sorensen@spectralink.com>
15---
16 grub-core/commands/ls.c | 2 +-
17 1 file changed, 1 insertion(+), 1 deletion(-)
18
19diff --git a/grub-core/commands/ls.c b/grub-core/commands/ls.c
20index 5b7491a..326d2d6 100644
21--- a/grub-core/commands/ls.c
22+++ b/grub-core/commands/ls.c
23@@ -196,7 +196,7 @@ grub_ls_list_files (char *dirname, int longlist, int all, int human)
24       goto fail;
25     }
26
27-  if (! *path)
28+  if (! *path && device_name)
29     {
30       if (grub_errno == GRUB_ERR_UNKNOWN_FS)
31 	grub_errno = GRUB_ERR_NONE;
32--
332.14.2
34
35