From: Thorsten Blum Date: Tue, 25 Feb 2025 23:21:27 +0000 (+0100) Subject: platform/x86: hp-bioscfg: Replace deprecated strncpy() with strscpy() X-Git-Tag: v6.15-rc1~172^2~18 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=baa18b6ed4200aff869e78f2650123572b6a9ad6;p=linux.git platform/x86: hp-bioscfg: Replace deprecated strncpy() with strscpy() Since kstrtol() requires a NUL-terminated string as input and 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@vger.kernel.org Signed-off-by: Thorsten Blum Link: https://lore.kernel.org/r/20250225232126.356274-2-thorsten.blum@linux.dev Reviewed-by: Ilpo Järvinen Signed-off-by: Ilpo Järvinen --- diff --git a/drivers/platform/x86/hp/hp-bioscfg/bioscfg.c b/drivers/platform/x86/hp/hp-bioscfg/bioscfg.c index 63c78b4d8258..13237890fc92 100644 --- a/drivers/platform/x86/hp/hp-bioscfg/bioscfg.c +++ b/drivers/platform/x86/hp/hp-bioscfg/bioscfg.c @@ -445,7 +445,7 @@ int hp_convert_hexstr_to_str(const char *input, u32 input_len, char **str, int * return -ENOMEM; for (i = 0; i < input_len; i += 5) { - strncpy(tmp, input + i, strlen(tmp)); + strscpy(tmp, input + i); if (kstrtol(tmp, 16, &ch) == 0) { // escape char if (ch == '\\' ||