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 25, 2024
1 parent 845a17b commit 71887e7
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/include/openamp/remoteproc.h
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ int remoteproc_remove(struct remoteproc *rproc);
* @brief Initialize remoteproc memory
*
* @param mem Pointer to remoteproc memory
* @param name Memory name
* @param name Memory name (max string size \ref RPROC_MAX_NAME_LEN)
* @param pa Physical address
* @param da Device address
* @param size Memory size
Expand Down
2 changes: 1 addition & 1 deletion lib/remoteproc/remoteproc.c
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ 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, RPROC_MAX_NAME_LEN);
else
mem->name[0] = 0;
mem->pa = pa;
Expand Down

0 comments on commit 71887e7

Please sign in to comment.