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

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