]> Git Repo - J-linux.git/commitdiff
xfrm: replace deprecated strncpy with strscpy_pad
authorDaniel Yang <[email protected]>
Wed, 13 Nov 2024 09:20:58 +0000 (01:20 -0800)
committerSteffen Klassert <[email protected]>
Thu, 14 Nov 2024 10:38:37 +0000 (11:38 +0100)
The function strncpy is deprecated since it does not guarantee the
destination buffer is NULL terminated. Recommended replacement is
strscpy. The padded version was used to remain consistent with the other
strscpy_pad usage in the modified function.

Signed-off-by: Daniel Yang <[email protected]>
Signed-off-by: Steffen Klassert <[email protected]>
net/xfrm/xfrm_user.c

index fab18b85af539c88f722227a8dcc54038355c0ce..6b0800c7c75e2e352ba663696ff5a0fd708a1c55 100644 (file)
@@ -1101,7 +1101,7 @@ static int copy_to_user_auth(struct xfrm_algo_auth *auth, struct sk_buff *skb)
        if (!nla)
                return -EMSGSIZE;
        algo = nla_data(nla);
-       strncpy(algo->alg_name, auth->alg_name, sizeof(algo->alg_name));
+       strscpy_pad(algo->alg_name, auth->alg_name, sizeof(algo->alg_name));
 
        if (redact_secret && auth->alg_key_len)
                memset(algo->alg_key, 0, (auth->alg_key_len + 7) / 8);
This page took 0.049649 seconds and 4 git commands to generate.