]> git.ipfire.org Git - thirdparty/rrdtool-1.x.git/commitdiff
be a bit more careful with what we accept from the callbacks
authorTobias Oetiker <tobi@oetiker.ch>
Mon, 9 Feb 2015 09:48:06 +0000 (10:48 +0100)
committerTobias Oetiker <tobi@oetiker.ch>
Mon, 9 Feb 2015 09:48:06 +0000 (10:48 +0100)
src/rrd_fetch_cb.c

index b7dde7e0399c4dbb2ee797c03493f00317e2f058..e3f398370d184aa5f029a8bd3593ea26d5178a71 100644 (file)
@@ -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;
+     }
 }