]> git.itanic.dy.fi Git - rrdd/commitdiff
rrdtool: Fix use of uninitialized buffers in string operations
authorTimo Kokkonen <timo.t.kokkonen@iki.fi>
Sat, 25 Apr 2020 14:49:26 +0000 (17:49 +0300)
committerTimo Kokkonen <timo.t.kokkonen@iki.fi>
Sat, 25 Apr 2020 14:49:26 +0000 (17:49 +0300)
The code is completely mess, referring to incorrect buffers as it is
calculating the size of the buffer. This wouldn't be problem as both
buffers are same length, but for some reason the code is also using
strlen() for something.

Fix up the mess.

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

index 7c0646d835e075d36af6c86ef881e842724dc007..ee4b111bbcfc626b4a7c815e68c3a72f4b655836 100644 (file)
--- a/rrdtool.c
+++ b/rrdtool.c
@@ -47,8 +47,9 @@ int rrdtool_draw_image(struct rrd_image *image)
        pr_info("Drawing image %s\n", image->image_filename);
 
        tmpfile[0] = 0;
-       strncat(tmpfile, image->image_filename, sizeof(tmp) - strlen(tmp) - 1);
-       strncat(tmpfile, ".tmp", sizeof(tmp) - strlen(tmp) - 1);
+       tmp[0] = 0;
+       strncat(tmpfile, image->image_filename, sizeof(tmpfile) - 1);
+       strncat(tmpfile, ".tmp", sizeof(tmpfile) - 1);
 
        if (image->updatestr)
                updatestr = image->updatestr;