1From a2a7464e9f10a677d6f91e1c4fa527d084c22e7c Mon Sep 17 00:00:00 2001
2From: Peter Jones <pjones@redhat.com>
3Date: Fri, 24 Jul 2020 13:57:27 -0400
4Subject: [PATCH] loader/linux: Avoid overflow on initrd size calculation
5MIME-Version: 1.0
6Content-Type: text/plain; charset=UTF-8
7Content-Transfer-Encoding: 8bit
8
9Signed-off-by: Peter Jones <pjones@redhat.com>
10Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
11Signed-off-by: Stefan Sørensen <stefan.sorensen@spectralink.com>
12---
13 grub-core/loader/linux.c | 3 +--
14 1 file changed, 1 insertion(+), 2 deletions(-)
15
16diff --git a/grub-core/loader/linux.c b/grub-core/loader/linux.c
17index 471b214d6..4cd8c20c7 100644
18--- a/grub-core/loader/linux.c
19+++ b/grub-core/loader/linux.c
20@@ -151,8 +151,7 @@ grub_initrd_init (int argc, char *argv[],
21   initrd_ctx->nfiles = 0;
22   initrd_ctx->components = 0;
23
24-  initrd_ctx->components = grub_zalloc (argc
25-					* sizeof (initrd_ctx->components[0]));
26+  initrd_ctx->components = grub_calloc (argc, sizeof (initrd_ctx->components[0]));
27   if (!initrd_ctx->components)
28     return grub_errno;
29
30--
312.26.2
32
33