Skip to content

Commit

Permalink
lib: remoteproc: replace strncpy with internal strlcpy
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
arnopo committed Sep 30, 2024
1 parent e83acc9 commit b160607
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/remoteproc/remoteproc.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* SPDX-License-Identifier: BSD-3-Clause
*/

#include <internal/string.h>
#include <metal/alloc.h>
#include <metal/log.h>
#include <metal/utilities.h>
Expand Down Expand Up @@ -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)strlcpy(mem->name, name, sizeof(mem->name));
else
mem->name[0] = 0;
mem->pa = pa;
Expand Down

0 comments on commit b160607

Please sign in to comment.