Skip to content

Commit b735edb

Browse files
committed
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 <arnaud.pouliquen@foss.st.com> (cherry picked from commit b1606070c9109ac581e1aa8dcff2871d0207e839) Upstream PR: OpenAMP/open-amp#620 Signed-off-by: Tomi Fontanilles <tomi.fontanilles@nordicsemi.no> Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
1 parent e272973 commit b735edb

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

open-amp/lib/remoteproc/remoteproc.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* SPDX-License-Identifier: BSD-3-Clause
77
*/
88

9+
#include <internal/string.h>
910
#include <metal/alloc.h>
1011
#include <metal/log.h>
1112
#include <metal/utilities.h>
@@ -300,7 +301,7 @@ void remoteproc_init_mem(struct remoteproc_mem *mem, const char *name,
300301
if (!mem || !io || size == 0)
301302
return;
302303
if (name)
303-
strncpy(mem->name, name, sizeof(mem->name));
304+
(void)strlcpy(mem->name, name, sizeof(mem->name));
304305
else
305306
mem->name[0] = 0;
306307
mem->pa = pa;

0 commit comments

Comments
 (0)