From: Tobias Oetiker Date: Tue, 19 Mar 2013 06:08:53 +0000 (+0100) Subject: fixed overflow probem with partial matching X-Git-Tag: v1.5.0-rc1~185 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9d65aa0ac97d1019ef5059e05f45e36cd48fc9a2;p=thirdparty%2Frrdtool-1.x.git fixed overflow probem with partial matching --- diff --git a/src/rrd_fetch.c b/src/rrd_fetch.c index e88580cf..94e88327 100644 --- a/src/rrd_fetch.c +++ b/src/rrd_fetch.c @@ -56,7 +56,7 @@ #include "rrd_client.h" #include "rrd_is_thread_safe.h" -/* #define DEBUG */ +/* #define DEBUG */ int rrd_fetch( int argc, @@ -404,12 +404,12 @@ int rrd_fetch_fn( 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; - end_offset = ((long) rra_end_time - *end) / (long) *step; + start_offset = ((long long)*start + (long long)*step - (long long)rra_start_time) / (long long) *step; + end_offset = ((long long)rra_end_time - (long long)*end) / (long long) *step; #ifdef DEBUG fprintf(stderr, - "rra_start %lu, rra_end %lu, start_off %li, end_off %li\n", - rra_start_time, rra_end_time, start_offset, end_offset); + "start %10lu step %10lu rra_start %lld, rra_end %lld, start_off %lld, end_off %lld\n", + *start, *step,(long long)rra_start_time, (long long)rra_end_time, (long long)start_offset, (long long)end_offset); #endif /* only seek if the start time is before the end time */ if (*start <= rra_end_time && *end >= rra_start_time - (off_t)*step ){