From: Daniel Yang Date: Wed, 13 Nov 2024 09:20:58 +0000 (-0800) Subject: xfrm: replace deprecated strncpy with strscpy_pad X-Git-Tag: v6.13-rc1~135^2~23^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9e1a6db68e3ccc5c20fd2d6243285d1cc7215fe4;p=thirdparty%2Flinux.git xfrm: replace deprecated strncpy with strscpy_pad 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 Signed-off-by: Steffen Klassert --- diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c index fab18b85af539..6b0800c7c75e2 100644 --- a/net/xfrm/xfrm_user.c +++ b/net/xfrm/xfrm_user.c @@ -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);