[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <25793e9f-211e-4e4e-86ac-88e3b902fb68@roeck-us.net>
Date: Thu, 27 Feb 2025 14:37:10 -0800
From: Guenter Roeck <linux@...ck-us.net>
To: Thorsten Blum <thorsten.blum@...ux.dev>, 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>
Cc: 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 2/27/25 09:39, 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>
> ---
> 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);
What guarantees that strlen(lstring) < sizeof(label->label) ?
Guenter
> else
> snprintf(label->label, sizeof(label->label), "%s.%d",
> lstring, phase);
Powered by blists - more mailing lists