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 <[email protected]>
(cherry picked from commit b1606070c9109ac581e1aa8dcff2871d0207e839)

Upstream PR: OpenAMP/open-amp#620

Signed-off-by: Tomi Fontanilles <[email protected]>
Signed-off-by: Torsten Rasmussen <[email protected]>
  • Loading branch information
arnopo committed Oct 2, 2024
1 parent e272973 commit b735edb
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion open-amp/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 @@ -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;
Expand Down

0 comments on commit b735edb

Please sign in to comment.