mirror of
https://git.savannah.gnu.org/git/grub.git
synced 2026-10-20 22:48:22 +00:00
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:
1 parent
05be856a8c
commit
0bf56bce47
1 file changed
+5
-1
@@ -241,7 +241,11 @@ grub_ls_list_files (char *dirname, int longlist, int all, int human)
|
|||||||
|
|
||||||
grub_file_close (file);
|
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);
|
ctx.dirname = grub_strndup (dirname, p - dirname);
|
||||||
if (ctx.dirname == NULL)
|
if (ctx.dirname == NULL)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|||||||
Reference in new issue
Block a user