1From bc9c468a2ce84bc767234eec888b71f1bc744fff Mon Sep 17 00:00:00 2001 2From: Darren Kenny <darren.kenny@oracle.com> 3Date: Fri, 23 Oct 2020 09:49:59 +0000 4Subject: [PATCH] kern/partition: Check for NULL before dereferencing input 5 string 6 7There is the possibility that the value of str comes from an external 8source and continuing to use it before ever checking its validity is 9wrong. So, needs fixing. 10 11Additionally, drop unneeded part initialization. 12 13Fixes: CID 292444 14 15Signed-off-by: Darren Kenny <darren.kenny@oracle.com> 16Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com> 17Signed-off-by: Stefan Sørensen <stefan.sorensen@spectralink.com> 18--- 19 grub-core/kern/partition.c | 5 ++++- 20 1 file changed, 4 insertions(+), 1 deletion(-) 21 22diff --git a/grub-core/kern/partition.c b/grub-core/kern/partition.c 23index e499147..b10a184 100644 24--- a/grub-core/kern/partition.c 25+++ b/grub-core/kern/partition.c 26@@ -109,11 +109,14 @@ grub_partition_map_probe (const grub_partition_map_t partmap, 27 grub_partition_t 28 grub_partition_probe (struct grub_disk *disk, const char *str) 29 { 30- grub_partition_t part = 0; 31+ grub_partition_t part; 32 grub_partition_t curpart = 0; 33 grub_partition_t tail; 34 const char *ptr; 35 36+ if (str == NULL) 37+ return 0; 38+ 39 part = tail = disk->partition; 40 41 for (ptr = str; *ptr;) 42-- 432.14.2 44 45