Blob Blame History Raw
From 2e018c08b92c800961ec010a6a4eeb34e8f3faa0 Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Tue, 9 May 2017 16:46:13 -0400
Subject: [PATCH 3/4] make_linux_load_option(): check data_size correctly.

Coverity noticed that we're not checking data_size for NULLness before
dereferencing it to pass the value to efi_loadopt_create().  So now we
pass a temporary variable and assign it only if it's non-NULL.

Signed-off-by: Peter Jones <pjones@redhat.com>
---
 src/efi.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/efi.c b/src/efi.c
index 8e2664e..cf4ada6 100644
--- a/src/efi.c
+++ b/src/efi.c
@@ -397,7 +397,10 @@ make_linux_load_option(uint8_t **data, size_t *data_size,
 		}
 	}
 
-	needed = efi_loadopt_create(*data, *data_size,
+	size_t data_size_tmp = 0;
+	if (data_size)
+		data_size_tmp = *data_size;
+	needed = efi_loadopt_create(*data, data_size_tmp,
 				      attributes, dp, needed, opts.label,
 				      optional_data, optional_data_size);
 	if (dp) {
-- 
2.12.2