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]
Message-ID: <20250317154706711RvRh_96VDw-u63cPmkeHk@zte.com.cn>
Date: Mon, 17 Mar 2025 15:47:06 +0800 (CST)
From: <feng.wei8@....com.cn>
To: <andrii@...nel.org>
Cc: <eddyz87@...il.com>, <mykolal@...com>, <ast@...nel.org>,
        <daniel@...earbox.net>, <martin.lau@...ux.dev>, <song@...nel.org>,
        <yonghong.song@...ux.dev>, <john.fastabend@...il.com>,
        <kpsingh@...nel.org>, <sdf@...ichev.me>, <haoluo@...gle.com>,
        <jolsa@...nel.org>, <shuah@...nel.org>, <bpf@...r.kernel.org>,
        <linux-kselftest@...r.kernel.org>, <linux-kernel@...r.kernel.org>
Subject: [PATCH] selftests/bpf: Replace deprecated strncpy() with strscpy()

From: FengWei <feng.wei8@....com.cn>

strncpy() is deprecated for NUL-terminated destination buffers. Use
strscpy() instead and remove the manual NUL-termination.

Signed-off-by: FengWei <feng.wei8@....com.cn>
---
 tools/testing/selftests/bpf/test_verifier.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/tools/testing/selftests/bpf/test_verifier.c b/tools/testing/selftests/bpf/test_verifier.c
index 447b68509d76..dfe64c6d4f87 100644
--- a/tools/testing/selftests/bpf/test_verifier.c
+++ b/tools/testing/selftests/bpf/test_verifier.c
@@ -1320,8 +1320,7 @@ static bool cmp_str_seq(const char *log, const char *exp)
 			printf("FAIL\nTestcase bug\n");
 			return false;
 		}
-		strncpy(needle, exp, len);
-		needle[len] = 0;
+		strscpy(needle, exp, len);
 		q = strstr(log, needle);
 		if (!q) {
 			printf("FAIL\nUnexpected verifier log!\n"
-- 
2.25.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ