Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Input: synaptics-rmi4 - replace deprecated strncpy

`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>

authored by

Justin Stitt and committed by
Dmitry Torokhov
96609688 c50fdc48

+1 -1
+1 -1
drivers/input/rmi4/rmi_f34.c
··· 471 471 if (buf[count - 1] == '\0' || buf[count - 1] == '\n') 472 472 copy_count -= 1; 473 473 474 - strncpy(fw_name, buf, copy_count); 474 + memcpy(fw_name, buf, copy_count); 475 475 fw_name[copy_count] = '\0'; 476 476 477 477 ret = request_firmware(&fw, fw_name, dev);