0093-commands-ls-Require-device_name-is-not-NULL-before-p.patch 1.0 KB

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