From 7d58b3085c6ebaa02cf567f25a741b878ee0a87c Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Tue, 1 Sep 2015 19:16:06 -0500 Subject: vmstat: reset header pointer when looping Modifying the headers pointer when printing the headers causes a buffer overrun the second time they are printed. Use a local header pointer that is reset to the beginning of the buffer for each loop. --- toys/other/vmstat.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'toys/other/vmstat.c') diff --git a/toys/other/vmstat.c b/toys/other/vmstat.c index 9a38e452..5b79702b 100644 --- a/toys/other/vmstat.c +++ b/toys/other/vmstat.c @@ -96,14 +96,14 @@ void vmstat_main(void) // Print headers if (rows>3 && !(loop % (rows-3))) { + const char *header = headers; if (isatty(1)) terminal_size(0, &rows); else rows = 0; printf("procs -----------memory---------- ---swap-- -----io---- -system-- ----cpu----\n"); - for (i=0; i