- Resolves: CVE-2024-45779 CVE-2024-45778 CVE-2025-1118 - Resolves: CVE-2025-0677 CVE-2024-45782 CVE-2025-0690 - Resolves: CVE-2024-45783 CVE-2025-0624 CVE-2024-45776 - Resolves: CVE-2025-0622 CVE-2024-45774 CVE-2024-45775 - Resolves: CVE-2024-45781 CVE-2024-45780 - Resolves: #RHEL-79700 - Resolves: #RHEL-79341 - Resolves: #RHEL-79875 - Resolves: #RHEL-79849 - Resolves: #RHEL-79707 - Resolves: #RHEL-79857 - Resolves: #RHEL-79709 - Resolves: #RHEL-79846 - Resolves: #RHEL-75737 - Resolves: #RHEL-79713 - Resolves: #RHEL-73785 - Resolves: #RHEL-73787 - Resolves: #RHEL-79704 - Resolves: #RHEL-79702 Signed-off-by: Nicolas Frayer <nfrayer@redhat.com>
47 lines
1.5 KiB
Diff
47 lines
1.5 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Lidong Chen <lidong.chen@oracle.com>
|
|
Date: Thu, 6 Feb 2025 18:16:56 +0000
|
|
Subject: [PATCH] kern/partition: Add sanity check after grub_strtoul() call
|
|
|
|
The current code incorrectly assumes that both the input and the values
|
|
returned by grub_strtoul() are always valid which can lead to potential
|
|
errors. This fix ensures proper validation to prevent any unintended issues.
|
|
|
|
Fixes: CID 473843
|
|
|
|
Signed-off-by: Lidong Chen <lidong.chen@oracle.com>
|
|
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
|
|
---
|
|
grub-core/kern/partition.c | 12 ++++++++++--
|
|
1 file changed, 10 insertions(+), 2 deletions(-)
|
|
|
|
diff --git a/grub-core/kern/partition.c b/grub-core/kern/partition.c
|
|
index f3f125e75..144a7b6a6 100644
|
|
--- a/grub-core/kern/partition.c
|
|
+++ b/grub-core/kern/partition.c
|
|
@@ -125,14 +125,22 @@ grub_partition_probe (struct grub_disk *disk, const char *str)
|
|
for (ptr = str; *ptr;)
|
|
{
|
|
grub_partition_map_t partmap;
|
|
- int num;
|
|
+ unsigned long num;
|
|
const char *partname, *partname_end;
|
|
|
|
partname = ptr;
|
|
while (*ptr && grub_isalpha (*ptr))
|
|
ptr++;
|
|
partname_end = ptr;
|
|
- num = grub_strtoul (ptr, &ptr, 0) - 1;
|
|
+
|
|
+ num = grub_strtoul (ptr, &ptr, 0);
|
|
+ if (*ptr != '\0' || num == 0 || num > GRUB_INT_MAX)
|
|
+ {
|
|
+ grub_error (GRUB_ERR_BAD_NUMBER, N_("invalid partition number"));
|
|
+ return 0;
|
|
+ }
|
|
+
|
|
+ num -= 1;
|
|
|
|
curpart = 0;
|
|
/* Use the first partition map type found. */
|