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
false-positives).
Signed-off-by: Andrew Price <anprice@redhat.com>