diff --git a/parser.c b/parser.c index 738052b95..391ebfd7c 100644 --- a/parser.c +++ b/parser.c @@ -245,19 +245,43 @@ void process_pihole_log(int file) } if(!found) { - timeidx = counters.overTime; - validate_access("overTime", timeidx, false, __LINE__, __FUNCTION__, __FILE__); - // Set magic byte - overTime[timeidx].magic = MAGICBYTE; - overTime[timeidx].timestamp = overTimetimestamp; - overTime[timeidx].total = 0; - overTime[timeidx].blocked = 0; - overTime[timeidx].cached = 0; - overTime[timeidx].forwardnum = 0; - overTime[timeidx].forwarddata = NULL; - overTime[timeidx].querytypedata = calloc(2, sizeof(int)); - memory.querytypedata += 2*sizeof(int); - counters.overTime++; + // We loop over this to fill potential data holes with zeros + int nexttimestamp = 0; + if(counters.overTime != 0) + { + validate_access("overTime", counters.overTime-1, false, __LINE__, __FUNCTION__, __FILE__); + nexttimestamp = overTime[counters.overTime-1].timestamp + 600; + } + else + { + nexttimestamp = overTimetimestamp; + } + + while(overTimetimestamp >= nexttimestamp) + { + // Check struct size + memory_check(OVERTIME); + timeidx = counters.overTime; + validate_access("overTime", timeidx, false, __LINE__, __FUNCTION__, __FILE__); + // Set magic byte + overTime[timeidx].magic = MAGICBYTE; + overTime[timeidx].timestamp = nexttimestamp; + overTime[timeidx].total = 0; + overTime[timeidx].blocked = 0; + overTime[timeidx].cached = 0; + overTime[timeidx].forwardnum = 0; + overTime[timeidx].forwarddata = NULL; + overTime[timeidx].querytypedata = calloc(2, sizeof(int)); + memory.querytypedata += 2*sizeof(int); + counters.overTime++; + + // Update time stamp for next loop interation + if(counters.overTime != 0) + { + validate_access("overTime", counters.overTime-1, false, __LINE__, __FUNCTION__, __FILE__); + nexttimestamp = overTime[counters.overTime-1].timestamp + 600; + } + } } // Get domain