[rrd-developers] [PATCH]crash with rrd_fetch

Zou Guangxian trueweck at 163.com
Tue Nov 25 10:07:34 CET 2008


hi!

 

create a rrd database with the following statement:

#!/bin/sh

start=`date +'00:00 %m/%e/%Y'`

/usr/bin/rrdtool create $1.rrd \

  --start "$start" \

  --step 300 \

  DS:total:GAUGE:600:0:U \

  DS:new:GAUGE:600:0:U \

  RRA:LAST:0.5:1:288 \

  RRA:LAST:0.5:12:720 \

  RRA:LAST:0.5:288:37200 \

  RRA:AVERAGE:0.5:1:288 \

  RRA:AVERAGE:0.5:12:720 \

  RRA:AVERAGE:0.5:288:37200

 

when fetch data between several days with rrd_fetch, rrd_fecth will crash.
gdb the core file, finally I found that there is a overflow in rrd_fetch.c.
here is the patch

[CODE]

diff -Nur rrdtool-1.3.4/rrdtool-1.3.4/src/rrd_fetch.c
rrdtool-1.3.4_/rrdtool-1.3.4/src/rrd_fetch.c

--- rrdtool-1.3.4/rrdtool-1.3.4/src/rrd_fetch.c         Sun Oct  5 00:04:04
2008

+++ rrdtool-1.3.4_/rrdtool-1.3.4/src/rrd_fetch.c   Tue Nov 25 16:55:04 2008

@@ -345,7 +345,7 @@

     rra_start_time = (rra_end_time

                       - (*step * (rrd.rra_def[chosen_rra].row_cnt - 1)));

     /* here's an error by one if we don't be careful */

-    start_offset = (long) (*start + *step - rra_start_time) / (long) *step;

+    start_offset = (long)(((double)(*start)/(long)*step) + 1 -
((double)(rra_start_time)/(long)*step));

     end_offset = (long) (rra_end_time - *end) / (long) *step;

 #ifdef DEBUG

     fprintf(stderr,

[/CODE]

 

--

zou guangxian 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.oetiker.ch/pipermail/rrd-developers/attachments/20081125/d073bed3/attachment.html 


More information about the rrd-developers mailing list