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

Create and use a temporary copy of the domain string during the analysis #859

Merged
merged 1 commit into from
Aug 9, 2020
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
10 changes: 8 additions & 2 deletions src/dnsmasq_interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ static bool _FTL_check_blocking(int queryID, int domainID, int clientID, const c
// Skip the entire chain of tests if we already know the answer for this
// particular client
unsigned char blockingStatus = dns_cache->blocking_status;
const char* domainstr = getstr(domain->domainpos);
char *domainstr = (char*)getstr(domain->domainpos);
switch(blockingStatus)
{
case UNKNOWN_BLOCKED:
Expand Down Expand Up @@ -252,8 +252,13 @@ static bool _FTL_check_blocking(int queryID, int domainID, int clientID, const c
return false;
}

// Check whitelist (exact + regex) for match
// Make a local copy of the domain string. The string memory may get
// reorganized in the following. We cannot expect domainstr to remain
// valid for all time.
domainstr = strdup(domainstr);
const char *blockedDomain = domainstr;

// Check whitelist (exact + regex) for match
query->whitelisted = in_whitelist(domainstr, clientID, client);

bool blockDomain = false;
Expand Down Expand Up @@ -299,6 +304,7 @@ static bool _FTL_check_blocking(int queryID, int domainID, int clientID, const c
dns_cache->blocking_status = query->whitelisted ? WHITELISTED : NOT_BLOCKED;
}

free(domainstr);
return blockDomain;
}

Expand Down