commands/ls: Fix NULL dereference
The grub_strrchr() may return NULL when the dirname do not contain "/". This can happen on broken filesystems. Reported-by: B Horn <b@horn.uk> Signed-off-by: B Horn <b@horn.uk> Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
This commit is contained in:
parent
05be856a8c
commit
0bf56bce47
@ -241,7 +241,11 @@ grub_ls_list_files (char *dirname, int longlist, int all, int human)
|
||||
|
||||
grub_file_close (file);
|
||||
|
||||
p = grub_strrchr (dirname, '/') + 1;
|
||||
p = grub_strrchr (dirname, '/');
|
||||
if (p == NULL)
|
||||
goto fail;
|
||||
++p;
|
||||
|
||||
ctx.dirname = grub_strndup (dirname, p - dirname);
|
||||
if (ctx.dirname == NULL)
|
||||
goto fail;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user