From: Tobias Oetiker Date: Mon, 9 Feb 2015 09:48:06 +0000 (+0100) Subject: be a bit more careful with what we accept from the callbacks X-Git-Tag: v1.5.0-rc2~10 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a41a28380fc101ff427df5961a003f1a01d70936;p=thirdparty%2Frrdtool-1.x.git be a bit more careful with what we accept from the callbacks --- diff --git a/src/rrd_fetch_cb.c b/src/rrd_fetch_cb.c index b7dde7e0..e3f39837 100644 --- a/src/rrd_fetch_cb.c +++ b/src/rrd_fetch_cb.c @@ -19,17 +19,27 @@ rrd_fetch_fn_cb( time_t *start, time_t *end, /* which time frame do you want ? * will be changed to represent reality */ - unsigned long *step, /* which stepsize do you want? + unsigned long *step, /* which stepsize do you want? * will be changed to represent reality */ unsigned long *ds_cnt, /* number of data sources in file */ char ***ds_namv, /* names of data_sources */ rrd_value_t **data) /* two dimensional array containing the data */ { + int ret; if (callback){ - return callback(filename,cf_idx,start,end,step,ds_cnt,ds_namv,data); + ret = callback(filename,cf_idx,start,end,step,ds_cnt,ds_namv,data); + if (*start > *end){ + rrd_set_error("Your callback returns a start after end. start: %lld end: %lld",(long long int)*start,(long long int)*end); + return -1; + } + if (*step == 0){ + rrd_set_error("Your callback returns a step of 0"); + return -1; + } + return ret; } else { rrd_set_error("use rrd_fetch_cb_register to register your callback prior to calling rrd_fetch_fn_cb"); - return -1; - } + return -1; + } }