Re: [PATCH] selftests/bpf: Replace deprecated strncpy() with strscpy()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Mar 17, 2025 at 12:47 AM <feng.wei8@xxxxxxxxxx> wrote:
>
> From: FengWei <feng.wei8@xxxxxxxxxx>
>
> strncpy() is deprecated for NUL-terminated destination buffers. Use
> strscpy() instead and remove the manual NUL-termination.
>
> Signed-off-by: FengWei <feng.wei8@xxxxxxxxxx>
> ---
>  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





[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux