@cryptotaxi247 / netdata-1 / commits / 66f5cf19c

prevent loading files with future dates

Costa Tsaousis (ktsaou) committed Feb 23, 2017 at 20:59 UTC 66f5cf19c3c9f3ed649bc90c72bc053de0584ad7
1 file changed +8 -1
src/rrdset.c
+8 -1
@@ -331,6 +331,8 @@ RRDSET *rrdset_create(RRDHOST *host, const char *type, const char *id, const cha
331 unsigned long size = sizeof(RRDSET);
332 char *cache_dir = rrdset_cache_dir(host, fullid, config_section);
333
334 + time_t now = now_realtime_sec();
335 +
336 // ------------------------------------------------------------------------
337 // load it or allocate it
338
@@ -380,11 +382,16 @@ RRDSET *rrdset_create(RRDHOST *host, const char *type, const char *id, const cha
382 error("File %s does not have the desired update frequency. Clearing it.", fullfilename);
383 memset(st, 0, size);
384 }
383 - else if((now_realtime_sec() - st->last_updated.tv_sec) > update_every * entries) {
385 + else if((now - st->last_updated.tv_sec) > update_every * entries) {
386 errno = 0;
387 error("File %s is too old. Clearing it.", fullfilename);
388 memset(st, 0, size);
389 }
390 + else if(st->last_updated.tv_sec > now + update_every) {
391 + errno = 0;
392 + error("File %s refers to the future. Clearing it.", fullfilename);
393 + memset(st, 0, size);
394 + }
395
396 // make sure the database is aligned
397 if(st->last_updated.tv_sec)