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