nalika / rpms / grub2

Forked from rpms/grub2 2 years ago
Clone

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

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