Blob Blame Raw
From f6dc880cb1684d1836ade34e44c7710029c174e2 Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Mon, 1 May 2017 15:02:27 -0400
Subject: [PATCH 13/22] efi_variable_import(): constrain our inputs better.

efi_variable_import() could plausibly pass NULL to memcpy() if buf is 0
and size is < 0, though that should never be the case.  Make the input
checking return EINVAL if that's the case.

Found by Covscan.

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

diff --git a/src/loadopt.c b/src/loadopt.c
index a3c1ba9..d4c2d46 100644
--- a/src/loadopt.c
+++ b/src/loadopt.c
@@ -302,7 +302,7 @@ __attribute__((__visibility__ ("default")))
 efi_loadopt_args_as_utf8(uint8_t *buf, ssize_t size, uint8_t *utf8)
 {
 	ssize_t req;
-	if (!buf && size > 0) {
+	if (!buf && size != 0) {
 		errno = EINVAL;
 		return -1;
 	}
-- 
2.12.2