|
|
8e15ce |
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
8e15ce |
From: Peter Jones <pjones@redhat.com>
|
|
|
8e15ce |
Date: Sun, 19 Jul 2020 17:11:06 -0400
|
|
|
8e15ce |
Subject: [PATCH] efi+dhcp: fix some allocation error checking.
|
|
|
8e15ce |
|
|
|
8e15ce |
Signed-off-by: Peter Jones <pjones@redhat.com>
|
|
|
8e15ce |
---
|
|
|
8e15ce |
grub-core/net/efi/dhcp.c | 9 ++++++---
|
|
|
8e15ce |
1 file changed, 6 insertions(+), 3 deletions(-)
|
|
|
8e15ce |
|
|
|
8e15ce |
diff --git a/grub-core/net/efi/dhcp.c b/grub-core/net/efi/dhcp.c
|
|
|
8e15ce |
index dbef63d8c08..e5c79b748b0 100644
|
|
|
8e15ce |
--- a/grub-core/net/efi/dhcp.c
|
|
|
8e15ce |
+++ b/grub-core/net/efi/dhcp.c
|
|
|
8e15ce |
@@ -80,7 +80,7 @@ grub_efi_dhcp4_parse_dns (grub_efi_dhcp4_protocol_t *dhcp4, grub_efi_dhcp4_packe
|
|
|
8e15ce |
if (status != GRUB_EFI_BUFFER_TOO_SMALL)
|
|
|
8e15ce |
return NULL;
|
|
|
8e15ce |
|
|
|
8e15ce |
- option_list = grub_malloc (option_count * sizeof(*option_list));
|
|
|
8e15ce |
+ option_list = grub_calloc (option_count, sizeof(*option_list));
|
|
|
8e15ce |
if (!option_list)
|
|
|
8e15ce |
return NULL;
|
|
|
8e15ce |
|
|
|
8e15ce |
@@ -360,8 +360,11 @@ grub_cmd_efi_bootp6 (struct grub_command *cmd __attribute__ ((unused)),
|
|
|
8e15ce |
|
|
|
8e15ce |
if (status == GRUB_EFI_BUFFER_TOO_SMALL && count)
|
|
|
8e15ce |
{
|
|
|
8e15ce |
- options = grub_malloc (count * sizeof(*options));
|
|
|
8e15ce |
- status = efi_call_4 (dev->dhcp6->parse, dev->dhcp6, mode.ia->reply_packet, &count, options);
|
|
|
8e15ce |
+ options = grub_calloc (count, sizeof(*options));
|
|
|
8e15ce |
+ if (options)
|
|
|
8e15ce |
+ status = efi_call_4 (dev->dhcp6->parse, dev->dhcp6, mode.ia->reply_packet, &count, options);
|
|
|
8e15ce |
+ else
|
|
|
8e15ce |
+ status = GRUB_EFI_OUT_OF_RESOURCES;
|
|
|
8e15ce |
}
|
|
|
8e15ce |
|
|
|
8e15ce |
if (status != GRUB_EFI_SUCCESS)
|