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