]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
commands/ls: Require device_name is not NULL before printing
authorDaniel Axtens <dja@axtens.net>
Mon, 11 Jan 2021 05:57:37 +0000 (16:57 +1100)
committerDaniel Kiper <daniel.kiper@oracle.com>
Tue, 2 Mar 2021 14:54:17 +0000 (15:54 +0100)
This can be triggered with:
  ls -l (0 0*)
and causes a NULL deref in grub_normal_print_device_info().

I'm not sure if there's any implication with the IEEE 1275 platform.

Signed-off-by: Daniel Axtens <dja@axtens.net>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
grub-core/commands/ls.c

index 5b7491aa49b959a63a21d01567bd10b7d56ba5c2..326d2d6b41eda7dc2791a6ce9c519e55918c6f65 100644 (file)
@@ -196,7 +196,7 @@ grub_ls_list_files (char *dirname, int longlist, int all, int human)
       goto fail;
     }
 
-  if (! *path)
+  if (! *path && device_name)
     {
       if (grub_errno == GRUB_ERR_UNKNOWN_FS)
        grub_errno = GRUB_ERR_NONE;