From: Peter Jones Date: Wed, 4 Mar 2020 11:58:44 +0000 (+0100) Subject: normal/completion: Fix possible NULL pointer dereference X-Git-Tag: grub-2.06-rc1~301 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f0f97576e02208eb947c8da4bd14c54ea3573109;p=thirdparty%2Fgrub.git normal/completion: Fix possible NULL pointer dereference 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 Signed-off-by: Javier Martinez Canillas Reviewed-by: Daniel Kiper --- diff --git a/grub-core/normal/completion.c b/grub-core/normal/completion.c index 596102848..c07100a8d 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);