]> git.itanic.dy.fi Git - rrdd/commitdiff
rrdtool.c: Null terminate process argument list in add_arg
authorTimo Kokkonen <timo.t.kokkonen@iki.fi>
Sun, 26 Oct 2014 15:12:34 +0000 (17:12 +0200)
committerTimo Kokkonen <timo.t.kokkonen@iki.fi>
Sun, 26 Oct 2014 15:25:28 +0000 (17:25 +0200)
add_arg macro was not null teriminating argument list. Null
termination was left as an responsibility for the caller. This is
error prone as this requirement is not clear.

Add null termination in the add_arg macro so that caller does not need
to care about it.

Signed-off-by: Timo Kokkonen <timo.t.kokkonen@iki.fi>
rrdtool.c

index 9539c6813289ba531b14474ce7a367b0e60b54e3..df9b5c80fba4f788855b9f0c3fe3ceb888137ee1 100644 (file)
--- a/rrdtool.c
+++ b/rrdtool.c
@@ -29,6 +29,7 @@
        args[argcnt] = argstr + idx;                    \
        idx += sprintf(argstr + idx, fmt, ##arg);       \
        argcnt++;                                       \
+       args[argcnt] = 0;                               \
        argstr[++idx] = 0
 
 int rrdtool_draw_image(struct rrd_image *image)
@@ -94,8 +95,6 @@ int rrdtool_draw_image(struct rrd_image *image)
 
        add_arg(args, argcnt, argstr, idx, "COMMENT: %s\\c", timestamp);
 
-       args[argcnt] = 0;
-
        pid = run(cmd, args);
        harvest_zombies(pid);