1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- From d9f900247eb886176aace7888be941348a9c8fc8 Mon Sep 17 00:00:00 2001
- From: Alec Brown <alec.r.brown@oracle.com>
- Date: Wed, 22 Jan 2025 02:55:10 +0000
- Subject: [PATCH] disk: Prevent overflows when allocating memory for arrays
- Use grub_calloc() when allocating memory for arrays to ensure proper
- overflow checks are in place.
- Signed-off-by: Alec Brown <alec.r.brown@oracle.com>
- Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
- Conflicts:
- grub-core/disk/cryptodisk.c
- Upstream: d8151f98331ee4d15fcca59edffa59246d8fc15f
- Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
- ---
- grub-core/disk/lvm.c | 6 ++----
- 1 file changed, 2 insertions(+), 4 deletions(-)
- diff --git a/grub-core/disk/lvm.c b/grub-core/disk/lvm.c
- index 794248540..a395b200d 100644
- --- a/grub-core/disk/lvm.c
- +++ b/grub-core/disk/lvm.c
- @@ -671,8 +671,7 @@ grub_lvm_detect (grub_disk_t disk,
- goto lvs_segment_fail;
- }
-
- - seg->nodes = grub_zalloc (sizeof (seg->nodes[0])
- - * seg->node_count);
- + seg->nodes = grub_calloc (seg->node_count, sizeof (seg->nodes[0]));
-
- p = grub_strstr (p, "mirrors = [");
- if (p == NULL)
- @@ -760,8 +759,7 @@ grub_lvm_detect (grub_disk_t disk,
- }
- }
-
- - seg->nodes = grub_zalloc (sizeof (seg->nodes[0])
- - * seg->node_count);
- + seg->nodes = grub_calloc (seg->node_count, sizeof (seg->nodes[0]));
-
- p = grub_strstr (p, "raids = [");
- if (p == NULL)
- --
- 2.50.1
|