iowatcher: Fix up some strcpy and strcat usage

Fix an unchecked strcpy and strcat in plot_io_movie():

  $ ./iowatcher -t foo --movie -o foo.ogv -l $(printf 'x%.0s' {1..300})
  *** buffer overflow detected ***: ./iowatcher terminated

There was also very similar code in plot_io() so a new function
plot_io_legend() was added to factor out the common string building code
and replace the buggy code with asprintf().

Also add a closedir() call to an error path in traces_list() to plug a
resource leak and make iowatcher Coverity-clean (ignoring some

Signed-off-by: Andrew Price <>
2 files changed
tree: fac43ae29792cb4f35fd3089babff6709d6a7a11
  1. iowatcher/