Blob Blame History Raw
From a10e5ff7f8f69e1ed5cd4151f3e71f4783c40c68 Mon Sep 17 00:00:00 2001
From: Krzysztof Kozlowski <krzk@kernel.org>
Date: Thu, 12 Jul 2018 18:13:32 +0200
Subject: [PATCH] test: Be sure to terminate strncpy() copied string
 (-Wstringop-truncation)

strncpy() might not NULL-terminate the buffer.  This fixes GCC v8.1.0 warning:

    test/kcapi-main.c: In function 'main':
    test/kcapi-main.c:3123:5: error: 'strncpy' specified bound 63 equals destination size [-Werror=stringop-truncation]
         strncpy(cavs_test.cipher, optarg,
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          CIPHERMAXNAME);
          ~~~~~~~~~~~~~~

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Signed-off-by: Stephan Mueller <smueller@chronox.de>
---
 test/kcapi-main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/test/kcapi-main.c b/test/kcapi-main.c
index 8352499..c167b7f 100644
--- a/test/kcapi-main.c
+++ b/test/kcapi-main.c
@@ -3121,7 +3121,7 @@ int main(int argc, char *argv[])
 				break;
 			case 'c':
 				strncpy(cavs_test.cipher, optarg,
-					CIPHERMAXNAME);
+					CIPHERMAXNAME - 1);
 				break;
 			case 'p':
 				len = strlen(optarg);