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] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHp75Vch84NZhZa_Gy4qNO1-6ZJq3GBGmJXHSDurW5jeoYzhdQ@mail.gmail.com>
Date:   Sat, 3 Dec 2022 14:15:42 +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] x86/platform/uv: use strscpy to instead of strncpy()

On Sat, Dec 3, 2022 at 8:24 AM <yang.yang29@....com.cn> wrote:

> The implementation of strscpy() is more robust and safer.
> That's now the recommended way to copy NUL terminated strings.

...

>         /* (remove possible '\n') */
> -       strncpy(arg, val, ACTION_LEN - 1);
> -       arg[ACTION_LEN - 1] = '\0';
> +       strscpy(arg, val, ACTION_LEN - 1);

Should be ACTION_LEN here, no?

>         p = strchr(arg, '\n');
>         if (p)
>                 *p = '\0';

Wouldn't be better to refactor this

p = strnchrnul(val, ACTION_LEN, '\n');
strscpy(arg, val, p - val);

?

-- 
With Best Regards,
Andy Shevchenko

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ