Blame SOURCES/0307-efi-dhcp-fix-some-allocation-error-checking.patch

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