]> git.itanic.dy.fi Git - rrdd/blobdiff - rrdtool.c
rrdtool_update_data_multi: Discard entries with timestamp in future
[rrdd] / rrdtool.c
index 98844c596af11ed0d9dc5061d11507a996a2950e..ece5d12d7d5485954ab779b326d874fc2a79c6d4 100644 (file)
--- a/rrdtool.c
+++ b/rrdtool.c
@@ -276,6 +276,7 @@ static int rrdtool_update_data_multi(struct rrd_database *rrd)
                (char *const)rrd->filename,
        };
        int old_last_update = rrd->last_update;
+       time_t now = time(NULL);
 
        ret = rrd->parser->parse_multi(&data, rrd->parser_data,
                                &rrd->parser_state, rrd->last_update);
@@ -284,7 +285,7 @@ static int rrdtool_update_data_multi(struct rrd_database *rrd)
                goto out;
        }
 
-       for (i = 3, d = 0; i < ARRAY_SIZE(cmdline) - 1; i++, d++) {
+       for (i = 3, d = 0; i < ARRAY_SIZE(cmdline) - 1; d++) {
                time_t then;
 
                if (!data[d])
@@ -293,11 +294,17 @@ static int rrdtool_update_data_multi(struct rrd_database *rrd)
                sanitize_rrd_update_data(data[d]);
 
                then = atoi(data[d]);
+               if (then > now) {
+                       pr_err("Skipping bad data with timestamp in future: %ld > %ld\n",
+                               then, now);
+                       continue;
+               }
                write_to_logfile(rrd, data[d], then);
                cmdline[i] = data[d];
                pr_info("Data: %s\n", data[d]);
 
                rrd->last_update = then;
+               i++;
        }
 
        cmdline[i] = 0;