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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <f5b67a83-205c-42a5-a59f-cb5df877df99@roeck-us.net>
Date: Sun, 2 Mar 2025 08:29:40 -0800
From: Guenter Roeck <linux@...ck-us.net>
To: Thorsten Blum <thorsten.blum@...ux.dev>
Cc: Jean Delvare <jdelvare@...e.com>, Jerome Brunet <jbrunet@...libre.com>,
	Patryk Biel <pbiel7@...il.com>, Ninad Palsule <ninad@...ux.ibm.com>,
	Peter Zijlstra <peterz@...radead.org>,
	Patrick Rudolph <patrick.rudolph@...ements.com>,
	linux-hardening@...r.kernel.org, linux-hwmon@...r.kernel.org,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH] hwmon: (pmbus/core) Replace deprecated strncpy() with
 strscpy()

On Thu, Feb 27, 2025 at 06:39:33PM +0100, Thorsten Blum wrote:
> strncpy() is deprecated for NUL-terminated destination buffers; use
> strscpy() instead.
> 
> Compile-tested only.
> 
> Link: https://github.com/KSPP/linux/issues/90
> Cc: linux-hardening@...r.kernel.org
> Signed-off-by: Thorsten Blum <thorsten.blum@...ux.dev>

Applied.

> ---
>  drivers/hwmon/pmbus/pmbus_core.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
> index 787683e83db6..cdde8b03a6e9 100644
> --- a/drivers/hwmon/pmbus/pmbus_core.c
> +++ b/drivers/hwmon/pmbus/pmbus_core.c
> @@ -1470,8 +1470,7 @@ static int pmbus_add_label(struct pmbus_data *data,
>  	snprintf(label->name, sizeof(label->name), "%s%d_label", name, seq);
>  	if (!index) {
>  		if (phase == 0xff)
> -			strncpy(label->label, lstring,
> -				sizeof(label->label) - 1);
> +			strscpy(label->label, lstring);

I added a note explaining that strscpy() uses sizeof(label->label) if the
length of the destination buffer is not provided.

Guenter

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ