From: Masami Hiramatsu <masami.hiramatsu@linaro.org>
Date: Mon, 31 Jan 2022 02:52:20 +0000 (+0900)
Subject: DFU: Do not copy the entity name over the buffer size
X-Git-Tag: v2025.01-rc5-pxa1908~1537^2~9
X-Git-Url: http://git.dujemihanovic.xyz/%22mailto:Murray.Jensen%40csiro.au/static/%7B%7B?a=commitdiff_plain;h=d8ae90a8d47da2f22041bf9f6fd6d42a598f44ee;p=u-boot.git

DFU: Do not copy the entity name over the buffer size

Use strlcpy() instead of strcpy() to prevent copying the
entity name over the name buffer size.

Signed-off-by: Masami Hiramatsu <masami.hiramatsu@linaro.org>
---

diff --git a/drivers/dfu/dfu.c b/drivers/dfu/dfu.c
index af3975925a..66c41b5e76 100644
--- a/drivers/dfu/dfu.c
+++ b/drivers/dfu/dfu.c
@@ -503,7 +503,7 @@ static int dfu_fill_entity(struct dfu_entity *dfu, char *s, int alt,
 
 	debug("%s: %s interface: %s dev: %s\n", __func__, s, interface, devstr);
 	st = strsep(&s, " ");
-	strcpy(dfu->name, st);
+	strlcpy(dfu->name, st, DFU_NAME_SIZE);
 
 	dfu->alt = alt;
 	dfu->max_buf_size = 0;