Blame SOURCES/libkcapi-1.1.1-kcapi-hasher_Fix_off-by-one_error.patch

fe8dd0
From 94c8277dd8fbd2193cb3804c304e965c9238951d Mon Sep 17 00:00:00 2001
fe8dd0
From: Ondrej Mosnacek <omosnace@redhat.com>
fe8dd0
Date: Wed, 11 Jul 2018 14:41:14 +0200
fe8dd0
Subject: [PATCH] kcapi-hasher: Fix off-by-one error
fe8dd0
fe8dd0
There was an off-by-one error in process_checkfile() that caused the
fe8dd0
hasher to misparse checkfiles that contain only the hash (for
fe8dd0
self-check).
fe8dd0
---
fe8dd0
 apps/kcapi-hasher.c | 5 ++++-
fe8dd0
 1 file changed, 4 insertions(+), 1 deletion(-)
fe8dd0
fe8dd0
diff --git a/apps/kcapi-hasher.c b/apps/kcapi-hasher.c
fe8dd0
index ae88211..00f0373 100644
fe8dd0
--- a/apps/kcapi-hasher.c
fe8dd0
+++ b/apps/kcapi-hasher.c
fe8dd0
@@ -514,8 +514,11 @@ static int process_checkfile(const struct hash_params *params,
fe8dd0
 		uint32_t i;
fe8dd0
 		uint32_t bsd_style = 0; // >0 if --tag formatted style
fe8dd0
 
fe8dd0
+		if (linelen == 0)
fe8dd0
+			break;
fe8dd0
+
fe8dd0
 		/* remove trailing CR and reduce buffer length */
fe8dd0
-		for (i = linelen; i > 0; i--) {
fe8dd0
+		for (i = linelen - 1; i > 0; i--) {
fe8dd0
 			if (!isprint(buf[i])) {
fe8dd0
 				buf[i] = '\0';
fe8dd0
 				linelen--;