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

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