grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 05/10] normal/completion: Fix possible NULL pointer dereference


From: Javier Martinez Canillas
Subject: [PATCH 05/10] normal/completion: Fix possible NULL pointer dereference
Date: Tue, 25 Feb 2020 13:25:48 +0100

From: Peter Jones <address@hidden>

Coverity Scan reports that the grub_strrchr() function can return NULL if
the character is not found. Check if that's the case for dirfile pointer.

Signed-off-by: Peter Jones <address@hidden>
Signed-off-by: Javier Martinez Canillas <address@hidden>
---

 grub-core/normal/completion.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/grub-core/normal/completion.c b/grub-core/normal/completion.c
index 596102848c1..c07100a8de3 100644
--- a/grub-core/normal/completion.c
+++ b/grub-core/normal/completion.c
@@ -284,7 +284,8 @@ complete_file (void)
 
       /* Cut away the filename part.  */
       dirfile = grub_strrchr (dir, '/');
-      dirfile[1] = '\0';
+      if (dirfile)
+       dirfile[1] = '\0';
 
       /* Iterate the directory.  */
       (fs->fs_dir) (dev, dir, iterate_dir, NULL);
-- 
2.24.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]