From 2f440ba4a1e5f559d66a51b51aaf6a98469a3c01 Mon Sep 17 00:00:00 2001 From: Timo Kokkonen Date: Sat, 25 Apr 2020 17:49:26 +0300 Subject: [PATCH] rrdtool: Fix use of uninitialized buffers in string operations 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 --- rrdtool.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/rrdtool.c b/rrdtool.c index 7c0646d..ee4b111 100644 --- 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; -- 2.45.0