Blob Blame History Raw
From f8e032f150522c17094e36dcf62ec3ebc77e69d8 Mon Sep 17 00:00:00 2001
From: Ondrej Mosnacek <omosnace@redhat.com>
Date: Mon, 16 Apr 2018 15:39:03 +0200
Subject: [PATCH] kcapi-hasher: Fix buffer overrun in get_hmac_file

We need to allocate space also for the terminating null character...
---
 apps/kcapi-hasher.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/apps/kcapi-hasher.c b/apps/kcapi-hasher.c
index 861db79..2b87a45 100644
--- a/apps/kcapi-hasher.c
+++ b/apps/kcapi-hasher.c
@@ -360,7 +360,7 @@ static char *get_hmac_file(const char *filename)
 		fprintf(stderr, "File too long\n");
 		return NULL;
 	}
-	checkfile = malloc(filelen + prefixlen + 1 + suffixlen);
+	checkfile = malloc(filelen + prefixlen + 1 + suffixlen + 1);
 	if (!checkfile)
 		return NULL;