From ecaea015258daa726c0512d6f29e4186ad0fbe6d Mon Sep 17 00:00:00 2001 From: Sebastien GODARD Date: Sun, 22 Sep 2019 18:12:20 +0200 Subject: [PATCH] iostat: Check string's size when copying Make sure string's contents won't overflow. Fix CID#349502. Signed-off-by: Sebastien GODARD --- iostat.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/iostat.c b/iostat.c index ac9977d..34c4a87 100644 --- a/iostat.c +++ b/iostat.c @@ -249,7 +249,8 @@ struct io_device *add_list_device(struct io_device **dlist, char *name, int dtyp } memset(d->dev_stats[i], 0, sizeof(struct io_stats)); } - strcpy(d->name, name); + strncpy(d->name, name, MAX_NAME_LEN); + d->name[MAX_NAME_LEN - 1] = '\0'; d->exist = TRUE; d->next = ds; -- 2.40.0