Blob Blame Raw
From 20e9ecb4a4b327a32dc639a7ff826af5089e3fbf Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Mon, 1 May 2017 15:04:24 -0400
Subject: [PATCH 14/22] efi_loadopt_create(): check buf for NULLness.

Found by covscan.

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

diff --git a/src/loadopt.c b/src/loadopt.c
index d4c2d46..8db8074 100644
--- a/src/loadopt.c
+++ b/src/loadopt.c
@@ -46,13 +46,20 @@ efi_loadopt_create(uint8_t *buf, ssize_t size, uint32_t attributes,
 	ssize_t sz = sizeof (attributes)
 		     + sizeof (uint16_t) + desc_len
 		     + dp_size + optional_data_size;
+
 	if (size == 0)
 		return sz;
+
 	if (size < sz) {
 		errno = ENOSPC;
 		return -1;
 	}
 
+	if (!buf) {
+		errno = EINVAL;
+		return -1;
+	}
+
 	if (!optional_data && optional_data_size != 0) {
 		errno = EINVAL;
 		return -1;
-- 
2.12.2