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

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