Skip to content

Commit

Permalink
lib: remoteprocrpmsg: Fix safe_strcpy call
Browse files Browse the repository at this point in the history
Fix the size of the source string passed in argument of safe_strcpy().
In rpmsg_register_endpoint we can not trust the size of the name
string provided, so we limit the max size to RPROC_MAX_NAME_LEN.

Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com>
  • Loading branch information
arnopo committed Oct 21, 2024
1 parent d337fed commit 04309e7
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 @@ -307,7 +307,8 @@ void remoteproc_init_mem(struct remoteproc_mem *mem, const char *name,
if (!mem || !io || size == 0)
return;
if (name)
(void)safe_strcpy(mem->name, sizeof(mem->name), name, sizeof(name));
(void)safe_strcpy(mem->name, sizeof(mem->name), name,
strnlen(name, RPROC_MAX_NAME_LEN));
else
mem->name[0] = 0;
mem->pa = pa;
Expand Down

0 comments on commit 04309e7

Please sign in to comment.