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]
Date:   Mon, 5 Dec 2022 15:15:47 +0200
From:   Andy Shevchenko <andy.shevchenko@...il.com>
To:     yang.yang29@....com.cn
Cc:     steve.wahl@....com, mike.travis@....com, dimitri.sivanich@....com,
        russ.anderson@....com, dvhart@...radead.org, andy@...radead.org,
        tglx@...utronix.de, mingo@...hat.com, bp@...en8.de,
        dave.hansen@...ux.intel.com, x86@...nel.org, hpa@...or.com,
        platform-driver-x86@...r.kernel.org, linux-kernel@...r.kernel.org,
        xu.panda@....com.cn
Subject: Re: [PATCH linux-next v2] x86/platform/uv: use strscpy to instead of strncpy()

On Mon, Dec 5, 2022 at 3:13 PM Andy Shevchenko
<andy.shevchenko@...il.com> wrote:
> On Mon, Dec 5, 2022 at 1:42 PM <yang.yang29@....com.cn> wrote:

...

> >         char arg[ACTION_LEN], *p;
> >
> >         /* (remove possible '\n') */
> > -       strncpy(arg, val, ACTION_LEN - 1);
> > -       arg[ACTION_LEN - 1] = '\0';
> > -       p = strchr(arg, '\n');
> > -       if (p)
> > -               *p = '\0';
> > +       strscpy(arg, val, strnchrnul(val, ACTION_LEN, '\n') - val);
>
> And even better is to replace ACTION_LEN by sizeof(arg).

Btw, have you compiled this with `make W=1 ...`? I believe you will
get a new warning after your change.

-- 
With Best Regards,
Andy Shevchenko

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ