lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAH4c4j+CN552qxSy8OpSzyZysTMW=gRKjLR-GPYV9cPuvduFkA@mail.gmail.com>
Date: Wed, 18 Jun 2025 19:53:48 +0530
From: Pranav Tyagi <pranav.tyagi03@...il.com>
To: Simon Horman <horms@...nel.org>
Cc: jhs@...atatu.com, xiyou.wangcong@...il.com, jiri@...nulli.us, 
	davem@...emloft.net, edumazet@...gle.com, kuba@...nel.org, pabeni@...hat.com, 
	netdev@...r.kernel.org, linux-kernel@...r.kernel.org, 
	skhan@...uxfoundation.org, linux-kernel-mentees@...ts.linux.dev
Subject: Re: [PATCH net-next] net/sched: replace strncpy with strscpy

On Wed, Jun 18, 2025 at 4:24 PM Simon Horman <horms@...nel.org> wrote:
>
> On Tue, Jun 17, 2025 at 06:05:31PM +0530, Pranav Tyagi wrote:
> > Replace the deprecated strncpy() with strscpy() as the destination
> > buffer should be NUL-terminated and does not require any trailing
> > NUL-padding. Also, since NUL-termination is guaranteed,
> > use sizeof(conf.algo) in place of sizeof(conf.algo) - 1
> > as the size parameter.
> >
> > Signed-off-by: Pranav Tyagi <pranav.tyagi03@...il.com>
> > ---
> >  net/sched/em_text.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/net/sched/em_text.c b/net/sched/em_text.c
> > index 420c66203b17..1d0debfd62e5 100644
> > --- a/net/sched/em_text.c
> > +++ b/net/sched/em_text.c
> > @@ -108,7 +108,7 @@ static int em_text_dump(struct sk_buff *skb, struct tcf_ematch *m)
> >       struct text_match *tm = EM_TEXT_PRIV(m);
> >       struct tcf_em_text conf;
> >
> > -     strncpy(conf.algo, tm->config->ops->name, sizeof(conf.algo) - 1);
> > +     strscpy(conf.algo, tm->config->ops->name, sizeof(conf.algo));
>
> Hi Pranav,
>
> Because the destination is an array I think we can use the two-argument
> version of strscpy() here.
>
>         strscpy(conf.algo, tm->config->ops->name);
>
> >       conf.from_offset = tm->from_offset;
> >       conf.to_offset = tm->to_offset;
> >       conf.from_layer = tm->from_layer;
>
> --
> pw-bot: changes-requested

Hi,

Thanks for the feedback. I'll update the patch accordingly
and send a v2 for the same.

Regards
Pranav Tyagi

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ