]> git.ipfire.org Git - thirdparty/rrdtool-1.x.git/commitdiff
Fix #1268 - Segmentation Fault with Constant Lines
authorTheWitness <thewitness@cacti.net>
Fri, 15 Nov 2024 13:20:32 +0000 (08:20 -0500)
committerTheWitness <thewitness@cacti.net>
Fri, 15 Nov 2024 13:20:32 +0000 (08:20 -0500)
* This issue occurs with the --add-jsontime for lines that are a constant value.  In this case, the variable `im->gdes[vidx].step` is always 0, which results in a division by zero segmentation fault.

CHANGES
src/rrd_xport.c

diff --git a/CHANGES b/CHANGES
index f9f1ddc51333487f0fe11b4ad8ad3f6839869ffc..c9b7c1de91aa0f9ee8a71353468fadc758d22888 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -6,6 +6,7 @@ Bugfixes
 * Fix MacOS Build error (no SOCK_CLOEXEC on mac) @ensc fixes oetiker#1261
 * Fix build on 32bits platforms (like armhf) when time_t is 64bits, fixes #1264
 * Fix compilation on illumos @hadfl
+* Fix division by zero segfault when exporting a LINEx with a constant value
 
 Features
 --------
index f8a386187dda2a4241645ac4673f3519e320340f..b615b05a878826dfef4c8e56a0d272603591c0c2 100644 (file)
@@ -386,14 +386,10 @@ static int rrd_xport_fn(
             long      vidx = im->gdes[ref_list[i]].vidx;
             time_t    now = *start + dst_row * *step;
 
-            (*dstptr++) = im->gdes[vidx].data[(unsigned long)
-                                              floor((double)
-                                                    (now -
-                                                     im->gdes[vidx].start)
-                                                    / im->gdes[vidx].step)
-                                              * im->gdes[vidx].ds_cnt +
-                                              im->gdes[vidx].ds];
-
+            if (im->gdes[vidx].step > 0) {
+                (*dstptr++) = im->gdes[vidx].data[(unsigned long)
+                    floor((double) (now - im->gdes[vidx].start) / im->gdes[vidx].step) * im->gdes[vidx].ds_cnt + im->gdes[vidx].ds];
+            }
         }
     }