diff mbox series

[1/5] DFU: Do not copy the entity name over the buffer size

Message ID 163876947800.38238.12205367138412196203.stgit@localhost
State Superseded
Headers show
Series DFU: Update dfu_alt_info parser etc. | expand

Commit Message

Masami Hiramatsu Dec. 6, 2021, 5:44 a.m. UTC
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>
---
 drivers/dfu/dfu.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Ilias Apalodimas Jan. 3, 2022, 7:40 a.m. UTC | #1
On Mon, 6 Dec 2021 at 07:44, Masami Hiramatsu
<masami.hiramatsu@linaro.org> wrote:
>
> 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>
> ---
>  drivers/dfu/dfu.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> 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;
>

Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
diff mbox series

Patch

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;