Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure that data in overTime data struct in contiguous. #123

Merged
merged 3 commits into from
Aug 6, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 37 additions & 13 deletions parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down