From: FengWei feng.wei8@zte.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@zte.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"
On Mon, Mar 17, 2025 at 12:47 AM feng.wei8@zte.com.cn wrote:
From: FengWei feng.wei8@zte.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@zte.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);
Pls do not send patches that were not even build tested.
test_verifier.c:1323:3: error: call to undeclared function 'strscpy'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] 1323 | strscpy(needle, exp, len); 1 error generated.
pw-bot: cr
linux-kselftest-mirror@lists.linaro.org