EDAC/mc_sysfs: Replace deprecated strncpy() with memcpy()
authorJustin Stitt <justinstitt@google.com>
Mon, 18 Sep 2023 07:47:29 +0000 (07:47 +0000)
committerKees Cook <keescook@chromium.org>
Fri, 29 Sep 2023 21:48:32 +0000 (14:48 -0700)
commit6b343a46428255e7f383deda53b1ad38db513897
treeb7e71ae13738b5b3762b30834ceb39571f8ed96b
parent8046da444df5fc35ed12b6b52c090dc89c8a5f96
EDAC/mc_sysfs: Replace deprecated strncpy() with memcpy()

`strncpy` is deprecated for use on NUL-terminated destination strings [1].

We've already calculated bounds, possible truncation with '\0' or '\n'
and manually NUL-terminated. The situation is now just a literal byte
copy from one buffer to another, let's treat it as such and use a less
ambiguous interface in memcpy.

Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strncpy-on-nul-terminated-strings
Link: https://github.com/KSPP/linux/issues/90
Cc: linux-hardening@vger.kernel.org
Signed-off-by: Justin Stitt <justinstitt@google.com>
Reviewed-by: Kees Cook <keescook@chromium.org>
Link: https://lore.kernel.org/r/20230918-strncpy-drivers-edac-edac_mc_sysfs-c-v4-1-38a23d2fcdd8@google.com
Signed-off-by: Kees Cook <keescook@chromium.org>
drivers/edac/edac_mc_sysfs.c