iowatcher: Fix a label overflow in plot_io
authorAndrew Price <anprice@redhat.com>
Thu, 5 Sep 2013 16:35:04 +0000 (17:35 +0100)
committerChris Mason <clm@fb.com>
Wed, 24 Sep 2014 19:02:08 +0000 (12:02 -0700)
The length of the label option wasn't being checked before strcpy()ing
it into a char[256]. Use strncpy instead.

Signed-off-by: Andrew Price <anprice@redhat.com>
iowatcher/main.c

index 1444fbc1705deb5f1dc74541c09136f607c1944e..d23e3b25f03d73d5045b10c767a4bb93c79a5e94 100644 (file)
@@ -747,7 +747,8 @@ static void plot_io(struct plot *plot, int min_seconds, int max_seconds, u64 min
                if (!tf->label)
                        label[0] = 0;
                else {
-                       strcpy(label, tf->label);
+                       strncpy(label, tf->label, 255);
+                       label[255] = 0;
                        if (io_per_process)
                                strcat(label, " ");
                }