dcavalca / rpms / grub2

Forked from rpms/grub2 3 years ago
Clone

Blame SOURCES/0399-kern-partition-Check-for-NULL-before-dereferencing-i.patch

468bd4
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
468bd4
From: Darren Kenny <darren.kenny@oracle.com>
468bd4
Date: Fri, 23 Oct 2020 09:49:59 +0000
468bd4
Subject: [PATCH] kern/partition: Check for NULL before dereferencing input
468bd4
 string
468bd4
468bd4
There is the possibility that the value of str comes from an external
468bd4
source and continuing to use it before ever checking its validity is
468bd4
wrong. So, needs fixing.
468bd4
468bd4
Additionally, drop unneeded part initialization.
468bd4
468bd4
Fixes: CID 292444
468bd4
468bd4
Signed-off-by: Darren Kenny <darren.kenny@oracle.com>
468bd4
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
468bd4
---
468bd4
 grub-core/kern/partition.c | 5 ++++-
468bd4
 1 file changed, 4 insertions(+), 1 deletion(-)
468bd4
468bd4
diff --git a/grub-core/kern/partition.c b/grub-core/kern/partition.c
468bd4
index 2c401b866c4..3068c4dcac0 100644
468bd4
--- a/grub-core/kern/partition.c
468bd4
+++ b/grub-core/kern/partition.c
468bd4
@@ -109,11 +109,14 @@ grub_partition_map_probe (const grub_partition_map_t partmap,
468bd4
 grub_partition_t
468bd4
 grub_partition_probe (struct grub_disk *disk, const char *str)
468bd4
 {
468bd4
-  grub_partition_t part = 0;
468bd4
+  grub_partition_t part;
468bd4
   grub_partition_t curpart = 0;
468bd4
   grub_partition_t tail;
468bd4
   const char *ptr;
468bd4
 
468bd4
+  if (str == NULL)
468bd4
+    return 0;
468bd4
+
468bd4
   part = tail = disk->partition;
468bd4
 
468bd4
   for (ptr = str; *ptr;)