dcavalca / rpms / grub2

Forked from rpms/grub2 3 years ago
Clone

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

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