From 71887e71dfe0d5f5dfab0b989c9ff1829958f3a3 Mon Sep 17 00:00:00 2001 From: Arnaud Pouliquen Date: Mon, 21 Oct 2024 16:10:47 +0200 Subject: [PATCH] lib: remoteprocrpmsg: Fix safe_strcpy call 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 --- lib/include/openamp/remoteproc.h | 2 +- lib/remoteproc/remoteproc.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/include/openamp/remoteproc.h b/lib/include/openamp/remoteproc.h index 84bf2335..29b28ed0 100644 --- a/lib/include/openamp/remoteproc.h +++ b/lib/include/openamp/remoteproc.h @@ -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 diff --git a/lib/remoteproc/remoteproc.c b/lib/remoteproc/remoteproc.c index c6a019fa..95d4363b 100644 --- a/lib/remoteproc/remoteproc.c +++ b/lib/remoteproc/remoteproc.c @@ -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;