Re: [PATCH] hwmon: (pmbus/core) Replace deprecated strncpy() with strscpy()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxx
> Signed-off-by: Thorsten Blum <thorsten.blum@xxxxxxxxx>

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




[Index of Archives]     [LM Sensors]     [Linux Sound]     [ALSA Users]     [ALSA Devel]     [Linux Audio Users]     [Linux Media]     [Kernel]     [Gimp]     [Yosemite News]     [Linux Media]

  Powered by Linux