]> arthur.barton.de Git - netdata.git/commitdiff
prevent loading files with future dates
authorCosta Tsaousis (ktsaou) <costa@tsaousis.gr>
Thu, 23 Feb 2017 18:59:55 +0000 (20:59 +0200)
committerCosta Tsaousis (ktsaou) <costa@tsaousis.gr>
Thu, 23 Feb 2017 18:59:55 +0000 (20:59 +0200)
src/rrdset.c

index f88ce81804b1ceec2536ec36febb6419323fb6d0..d708be99bc5729f27d1c05d87eea3ea851f74f07 100644 (file)
@@ -331,6 +331,8 @@ RRDSET *rrdset_create(RRDHOST *host, const char *type, const char *id, const cha
     unsigned long size = sizeof(RRDSET);
     char *cache_dir = rrdset_cache_dir(host, fullid, config_section);
 
+    time_t now = now_realtime_sec();
+
     // ------------------------------------------------------------------------
     // load it or allocate it
 
@@ -380,11 +382,16 @@ RRDSET *rrdset_create(RRDHOST *host, const char *type, const char *id, const cha
                 error("File %s does not have the desired update frequency. Clearing it.", fullfilename);
                 memset(st, 0, size);
             }
-            else if((now_realtime_sec() - st->last_updated.tv_sec) > update_every * entries) {
+            else if((now - st->last_updated.tv_sec) > update_every * entries) {
                 errno = 0;
                 error("File %s is too old. Clearing it.", fullfilename);
                 memset(st, 0, size);
             }
+            else if(st->last_updated.tv_sec > now + update_every) {
+                errno = 0;
+                error("File %s refers to the future. Clearing it.", fullfilename);
+                memset(st, 0, size);
+            }
 
             // make sure the database is aligned
             if(st->last_updated.tv_sec)