From b735edbc739ad59156eb55bb8ce2583d74537719 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 strlcpy The strncpy function does not ensure that the destination string is null-terminated. To address this issue, replace strncpy with the internal strlcpy function, which guarantees null-termination of the destination string. Note: (void)strlcpy(...) indicates that the return value is intentionally ignored. Signed-off-by: Arnaud Pouliquen (cherry picked from commit b1606070c9109ac581e1aa8dcff2871d0207e839) Upstream PR: https://github.com/OpenAMP/open-amp/pull/620 Signed-off-by: Tomi Fontanilles Signed-off-by: Torsten Rasmussen --- open-amp/lib/remoteproc/remoteproc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/open-amp/lib/remoteproc/remoteproc.c b/open-amp/lib/remoteproc/remoteproc.c index eef3197..d7e3351 100644 --- a/open-amp/lib/remoteproc/remoteproc.c +++ b/open-amp/lib/remoteproc/remoteproc.c @@ -6,6 +6,7 @@ * SPDX-License-Identifier: BSD-3-Clause */ +#include #include #include #include @@ -300,7 +301,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)strlcpy(mem->name, name, sizeof(mem->name)); else mem->name[0] = 0; mem->pa = pa;