diff options
author | Costa Tsaousis (ktsaou) <costa@tsaousis.gr> | 2017-02-23 20:59:55 +0200 |
---|---|---|
committer | Costa Tsaousis (ktsaou) <costa@tsaousis.gr> | 2017-02-23 20:59:55 +0200 |
commit | 66f5cf19c3c9f3ed649bc90c72bc053de0584ad7 (patch) | |
tree | 923a292abf7563342894ee43d954f4d6b31e2f81 /src | |
parent | b41471251009dc3b37bfe8ad25a28ccbbb138174 (diff) |
prevent loading files with future dates
Diffstat (limited to 'src')
-rw-r--r-- | src/rrdset.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/rrdset.c b/src/rrdset.c index f88ce81804..d708be99bc 100644 --- a/src/rrdset.c +++ b/src/rrdset.c @@ -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) |