aboutsummaryrefslogtreecommitdiffstats
path: root/meta-oe/recipes-crypto/libkcapi/files/0003-test-Be-sure-to-terminate-strncpy-copied-string-Wstr.patch
blob: 885f3ca124654ad26aa615e2a22dd137a08ba729 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
From 505d949dcb6b756f6db6588d3425d9cd6108c77f Mon Sep 17 00:00:00 2001
From: Krzysztof Kozlowski <krzk@kernel.org>
Date: Thu, 12 Jul 2018 18:13:32 +0200
Subject: [PATCH 3/3] 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>
Upstream-Status: Submitted
---
 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 835249987aa5..c167b7f61809 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);
-- 
2.7.4