nalika / rpms / grub2

Forked from rpms/grub2 2 years ago
Clone

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

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