From: Sebastien GODARD Date: Sun, 22 Sep 2019 16:12:20 +0000 (+0200) Subject: iostat: Check string's size when copying X-Git-Tag: v12.1.7~8 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ecaea015258daa726c0512d6f29e4186ad0fbe6d;p=sysstat iostat: Check string's size when copying Make sure string's contents won't overflow. Fix CID#349502. Signed-off-by: Sebastien GODARD --- 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;