]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
platform/x86: hp-bioscfg: Replace deprecated strncpy() with strscpy()
authorThorsten Blum <thorsten.blum@linux.dev>
Tue, 25 Feb 2025 23:21:27 +0000 (00:21 +0100)
committerIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Mon, 3 Mar 2025 12:57:32 +0000 (14:57 +0200)
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 <thorsten.blum@linux.dev>
Link: https://lore.kernel.org/r/20250225232126.356274-2-thorsten.blum@linux.dev
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
drivers/platform/x86/hp/hp-bioscfg/bioscfg.c

index 63c78b4d8258dc19b739932a1cee311eb4073791..13237890fc92002e7e730b1c235ddf068a6737cd 100644 (file)
@@ -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 == '\\' ||