Input: synaptics-rmi4 - replace deprecated strncpy
authorJustin Stitt <justinstitt@google.com>
Sat, 30 Sep 2023 16:05:07 +0000 (09:05 -0700)
committerDmitry Torokhov <dmitry.torokhov@gmail.com>
Sat, 30 Sep 2023 16:24:15 +0000 (09:24 -0700)
`strncpy` is deprecated for use on NUL-terminated destination strings [1]

Let's use memcpy() as the bounds have already been checked and this
decays into a simple byte copy from one buffer to another removing any
ambiguity that strncpy has.

Signed-off-by: Justin Stitt <justinstitt@google.com>
Reviewed-by: Kees Cook <keescook@chromium.org>
Link: https://lore.kernel.org/r/20230921-strncpy-drivers-input-rmi4-rmi_f34-c-v1-1-4aef2e84b8d2@google.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
drivers/input/rmi4/rmi_f34.c

index 0d9a5756e3f5934ba8df6e4b0518687c74bc3a16..3b3ac71e53dc589e5c547ff4eec7cccd54564b8a 100644 (file)
@@ -471,7 +471,7 @@ static ssize_t rmi_driver_update_fw_store(struct device *dev,
        if (buf[count - 1] == '\0' || buf[count - 1] == '\n')
                copy_count -= 1;
 
-       strncpy(fw_name, buf, copy_count);
+       memcpy(fw_name, buf, copy_count);
        fw_name[copy_count] = '\0';
 
        ret = request_firmware(&fw, fw_name, dev);