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