]> granicus.if.org Git - sysstat/commitdiff
iostat: Check string's size when copying
authorSebastien GODARD <sysstat@users.noreply.github.com>
Sun, 22 Sep 2019 16:12:20 +0000 (18:12 +0200)
committerSebastien GODARD <sysstat@users.noreply.github.com>
Sun, 22 Sep 2019 16:12:20 +0000 (18:12 +0200)
Make sure string's contents won't overflow.
Fix CID#349502.

Signed-off-by: Sebastien GODARD <sysstat@users.noreply.github.com>
iostat.c

index ac9977da6c89970715ce8c3e2868c714b743233b..34c4a87faf6b923a0873ead27445855b7671e637 100644 (file)
--- 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;