* [PATCH net] xfrm: replace deprecated strncpy with strscpy_pad
@ 2024-11-13 9:20 Daniel Yang
2024-11-14 10:34 ` Paolo Abeni
2024-11-15 8:08 ` Steffen Klassert
0 siblings, 2 replies; 4+ messages in thread
From: Daniel Yang @ 2024-11-13 9:20 UTC (permalink / raw)
To: Steffen Klassert, Herbert Xu, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Simon Horman,
open list:NETWORKING [IPSEC],
open list
Cc: Daniel Yang
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 <danielyangkang@gmail.com>
---
net/xfrm/xfrm_user.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c
index e3b8ce898..085f68e35 100644
--- a/net/xfrm/xfrm_user.c
+++ b/net/xfrm/xfrm_user.c
@@ -1089,7 +1089,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);
--
2.39.5
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net] xfrm: replace deprecated strncpy with strscpy_pad
2024-11-13 9:20 [PATCH net] xfrm: replace deprecated strncpy with strscpy_pad Daniel Yang
@ 2024-11-14 10:34 ` Paolo Abeni
2024-11-14 10:37 ` Steffen Klassert
2024-11-15 8:08 ` Steffen Klassert
1 sibling, 1 reply; 4+ messages in thread
From: Paolo Abeni @ 2024-11-14 10:34 UTC (permalink / raw)
To: Daniel Yang, Steffen Klassert, Herbert Xu, David S. Miller,
Eric Dumazet, Jakub Kicinski, Simon Horman,
open list:NETWORKING [IPSEC],
open list
On 11/13/24 10:20, Daniel Yang wrote:
> 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 <danielyangkang@gmail.com>
> ---
> net/xfrm/xfrm_user.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c
> index e3b8ce898..085f68e35 100644
> --- a/net/xfrm/xfrm_user.c
> +++ b/net/xfrm/xfrm_user.c
> @@ -1089,7 +1089,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);
@Steffen, @Herbert: I think this should go via your tree despite the
prefix tag.
Please LMK otherwise!
Thanks,
Paolo
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net] xfrm: replace deprecated strncpy with strscpy_pad
2024-11-14 10:34 ` Paolo Abeni
@ 2024-11-14 10:37 ` Steffen Klassert
0 siblings, 0 replies; 4+ messages in thread
From: Steffen Klassert @ 2024-11-14 10:37 UTC (permalink / raw)
To: Paolo Abeni
Cc: Daniel Yang, Herbert Xu, David S. Miller, Eric Dumazet,
Jakub Kicinski, Simon Horman, open list:NETWORKING [IPSEC],
open list
On Thu, Nov 14, 2024 at 11:34:25AM +0100, Paolo Abeni wrote:
> On 11/13/24 10:20, Daniel Yang wrote:
> > 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 <danielyangkang@gmail.com>
> > ---
> > net/xfrm/xfrm_user.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c
> > index e3b8ce898..085f68e35 100644
> > --- a/net/xfrm/xfrm_user.c
> > +++ b/net/xfrm/xfrm_user.c
> > @@ -1089,7 +1089,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);
>
> @Steffen, @Herbert: I think this should go via your tree despite the
> prefix tag.
I'll take it into ipsec-next.
Thanks!
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net] xfrm: replace deprecated strncpy with strscpy_pad
2024-11-13 9:20 [PATCH net] xfrm: replace deprecated strncpy with strscpy_pad Daniel Yang
2024-11-14 10:34 ` Paolo Abeni
@ 2024-11-15 8:08 ` Steffen Klassert
1 sibling, 0 replies; 4+ messages in thread
From: Steffen Klassert @ 2024-11-15 8:08 UTC (permalink / raw)
To: Daniel Yang
Cc: Herbert Xu, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Simon Horman, open list:NETWORKING [IPSEC],
open list
On Wed, Nov 13, 2024 at 01:20:58AM -0800, Daniel Yang wrote:
> 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 <danielyangkang@gmail.com>
Applied to ipsec-next, thanks!
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-11-15 8:08 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-11-13 9:20 [PATCH net] xfrm: replace deprecated strncpy with strscpy_pad Daniel Yang
2024-11-14 10:34 ` Paolo Abeni
2024-11-14 10:37 ` Steffen Klassert
2024-11-15 8:08 ` Steffen Klassert
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®