Skip to content

Commit

Permalink
Fix #1268 - Segmentation Fault with Constant Lines
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
TheWitness committed Nov 15, 2024
1 parent 5041750 commit 866756e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -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
--------
Expand Down
12 changes: 4 additions & 8 deletions src/rrd_xport.c
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
}
}

Expand Down

0 comments on commit 866756e

Please sign in to comment.