Blame SOURCES/0308-efi-http-fix-some-allocation-error-checking.patch

9723a8
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
c294fc
From: Peter Jones <pjones@redhat.com>
c294fc
Date: Sun, 19 Jul 2020 17:14:15 -0400
9723a8
Subject: [PATCH] efi+http: fix some allocation error checking.
c294fc
c294fc
Signed-off-by: Peter Jones <pjones@redhat.com>
c294fc
---
c294fc
 grub-core/net/efi/http.c | 11 +++++++----
c294fc
 1 file changed, 7 insertions(+), 4 deletions(-)
c294fc
c294fc
diff --git a/grub-core/net/efi/http.c b/grub-core/net/efi/http.c
b71686
index fc8cb25ae..26647a50f 100644
c294fc
--- a/grub-core/net/efi/http.c
c294fc
+++ b/grub-core/net/efi/http.c
c294fc
@@ -412,8 +412,8 @@ grub_efihttp_open (struct grub_efi_net_device *dev,
c294fc
 		  int type)
c294fc
 {
c294fc
   grub_err_t err;
c294fc
-  grub_off_t size;
c294fc
-  char *buf;
c294fc
+  grub_off_t size = 0;
c294fc
+  char *buf = NULL;
c294fc
   char *file_name = NULL;
c294fc
   const char *http_path;
c294fc
 
c294fc
@@ -441,8 +441,11 @@ grub_efihttp_open (struct grub_efi_net_device *dev,
c294fc
       return err;
c294fc
     }
c294fc
 
c294fc
-  buf = grub_malloc (size);
c294fc
-  efihttp_read (dev, buf, size);
c294fc
+  if (size)
c294fc
+    {
c294fc
+      buf = grub_malloc (size);
c294fc
+      efihttp_read (dev, buf, size);
c294fc
+    }
c294fc
 
c294fc
   file->size = size;
c294fc
   file->data = buf;