mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-09 11:23:09 -04:00
hwmon: (pmbus/core) Replace deprecated strncpy() with strscpy()
strncpy() is deprecated for NUL-terminated destination buffers; use strscpy() instead. Compile-tested only. Note(groeck): strscpy() uses sizeof() to determine the length of the destination buffer if it is not provided as argument. Link: https://github.com/KSPP/linux/issues/90 Cc: linux-hardening@vger.kernel.org Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev> Link: https://lore.kernel.org/r/20250227173936.7746-2-thorsten.blum@linux.dev Signed-off-by: Guenter Roeck <linux@roeck-us.net>
This commit is contained in:
committed by
Guenter Roeck
parent
fafac0ebb2
commit
69af654bf9
@@ -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);
|
||||
else
|
||||
snprintf(label->label, sizeof(label->label), "%s.%d",
|
||||
lstring, phase);
|
||||
|
||||
Reference in New Issue
Block a user