Blame SOURCES/0015-efidp_duplicate_extra-error-if-our-allocation-is-too.patch

ac385c
From 32f6b0d5974e39dbcce89d9ab8551e35eb8fdaab Mon Sep 17 00:00:00 2001
ac385c
From: Peter Jones <pjones@redhat.com>
ac385c
Date: Mon, 1 May 2017 15:14:33 -0400
ac385c
Subject: [PATCH 15/22] efidp_duplicate_extra(): error if our allocation is too
ac385c
 small.
ac385c
ac385c
Covscan believes we might pass 0 to calloc(), though I suspect this is
ac385c
because it doesn't fully grok add().
ac385c
ac385c
Signed-off-by: Peter Jones <pjones@redhat.com>
ac385c
---
ac385c
 src/dp.c | 6 ++++++
ac385c
 1 file changed, 6 insertions(+)
ac385c
ac385c
diff --git a/src/dp.c b/src/dp.c
ac385c
index e700af9..eadb397 100644
ac385c
--- a/src/dp.c
ac385c
+++ b/src/dp.c
ac385c
@@ -81,6 +81,12 @@ efidp_duplicate_extra(const_efidp dp, efidp *out, size_t extra)
ac385c
 		return -1;
ac385c
 	}
ac385c
 
ac385c
+	if (plus < (ssize_t)sizeof(efidp_header)) {
ac385c
+		errno = EINVAL;
ac385c
+		efi_error("allocation for new device path is smaller than device path header.");
ac385c
+		return -1;
ac385c
+	}
ac385c
+
ac385c
 	new = calloc(1, plus);
ac385c
 	if (!new) {
ac385c
 		efi_error("allocation failed");
ac385c
-- 
ac385c
2.12.2
ac385c