lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Date:   Mon, 8 Jan 2018 20:34:17 +0800
From:   Xiongfeng Wang <wangxiongfeng2@...wei.com>
To:     <linux-kernel@...r.kernel.org>
CC:     <wangxiongfeng2@...wei.com>, <arnd@...db.de>
Subject: [PATCH] test_hexdump: use memcpy() to avoid warning print

From: Xiongfeng Wang <xiongfeng.wang@...aro.org>

gcc-8 reports

lib/test_hexdump.c: In function 'test_hexdump_prepare_test.isra.0':
./include/linux/string.h:245:9: warning: '__builtin_strncpy' output truncated
copying between 0 and 32 bytes from a string of length 32 [-Wstringop-truncation]

Since we don't need to copy '\0' in the end of the string, we can just
use memcpy() to avoid this warning.

Signed-off-by: Xiongfeng Wang <xiongfeng.wang@...aro.org>
---
 lib/test_hexdump.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/test_hexdump.c b/lib/test_hexdump.c
index 3f415d8..a495726 100644
--- a/lib/test_hexdump.c
+++ b/lib/test_hexdump.c
@@ -81,7 +81,7 @@ static void __init test_hexdump_prepare_test(size_t len, int rowsize,
 		const char *q = *result++;
 		size_t amount = strlen(q);
 
-		strncpy(p, q, amount);
+		memcpy(p, q, amount);
 		p += amount;
 
 		*p++ = ' ';
@@ -95,7 +95,7 @@ static void __init test_hexdump_prepare_test(size_t len, int rowsize,
 			*p++ = ' ';
 		} while (p < test + rs * 2 + rs / gs + 1);
 
-		strncpy(p, data_a, l);
+		memcpy(p, data_a, l);
 		p += l;
 	}
 
-- 
1.8.3.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ