nalika / rpms / grub2

Forked from rpms/grub2 2 years ago
Clone

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

c4e390
From 5a964a7f388dd0ecf865fc0fde802b561aab2fb6 Mon Sep 17 00:00:00 2001
c4e390
From: Peter Jones <pjones@redhat.com>
c4e390
Date: Sun, 19 Jul 2020 17:14:15 -0400
c4e390
Subject: [PATCH 328/336] 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;
c4e390
-- 
c4e390
2.26.2
c4e390