From 04309e76991404f7360d4f1f999f33f871b1c0a6 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/remoteproc/remoteproc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/remoteproc/remoteproc.c b/lib/remoteproc/remoteproc.c index c6a019fa..6e0cee20 100644 --- a/lib/remoteproc/remoteproc.c +++ b/lib/remoteproc/remoteproc.c @@ -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;