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

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