From e6fc6cd0b11f37e3d436d9c4c0b4c31d4a8c852b Mon Sep 17 00:00:00 2001 From: Arnaud Pouliquen Date: Mon, 30 Sep 2024 10:50:39 +0200 Subject: [PATCH] lib: remoteproc: replace strncpy with internal safe_strcpy The strncpy function does not ensure that the destination string is null-terminated. To address this issue, replace strncpy with the internal safe_strcpy() function, which guarantees null-termination of the destination string but also access only in buffer memory ranges. Note: (void)safe_strcpy(...) indicates that the return value is intentionally ignored. Signed-off-by: Arnaud Pouliquen --- lib/remoteproc/remoteproc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/remoteproc/remoteproc.c b/lib/remoteproc/remoteproc.c index 3ac4a1bb..c6a019fa 100644 --- a/lib/remoteproc/remoteproc.c +++ b/lib/remoteproc/remoteproc.c @@ -6,6 +6,7 @@ * SPDX-License-Identifier: BSD-3-Clause */ +#include #include #include #include @@ -306,7 +307,7 @@ void remoteproc_init_mem(struct remoteproc_mem *mem, const char *name, if (!mem || !io || size == 0) return; if (name) - strncpy(mem->name, name, sizeof(mem->name)); + (void)safe_strcpy(mem->name, sizeof(mem->name), name, sizeof(name)); else mem->name[0] = 0; mem->pa = pa;