diff options
author | Simon Kelley <simon@thekelleys.org.uk> | 2014-04-13 20:48:57 +0100 |
---|---|---|
committer | Simon Kelley <simon@thekelleys.org.uk> | 2014-04-13 20:48:57 +0100 |
commit | 82a14af5e742f685149ede3f3c3aa32e7ef97d6d (patch) | |
tree | aee555bac5bfe9b6c0b0089fc82ba2ee61bfbbaf /src | |
parent | 97dce08ed725be721ad2cc74c320e79dc9d6f895 (diff) | |
download | dnsmasq-82a14af5e742f685149ede3f3c3aa32e7ef97d6d.tar.gz |
Ensure request name in buffer for ipset lookup.
Diffstat (limited to 'src')
-rw-r--r-- | src/forward.c | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/src/forward.c b/src/forward.c index 83b55a4..37265da 100644 --- a/src/forward.c +++ b/src/forward.c @@ -535,20 +535,23 @@ static size_t process_reply(struct dns_header *header, time_t now, struct server (void) do_bit; #ifdef HAVE_IPSET - /* Similar algorithm to search_servers. */ - struct ipsets *ipset_pos; - unsigned int namelen = strlen(daemon->namebuff); - unsigned int matchlen = 0; - for (ipset_pos = daemon->ipsets; ipset_pos; ipset_pos = ipset_pos->next) + if (daemon->ipsets && extract_request(header, n, daemon->namebuff, NULL)) { - unsigned int domainlen = strlen(ipset_pos->domain); - char *matchstart = daemon->namebuff + namelen - domainlen; - if (namelen >= domainlen && hostname_isequal(matchstart, ipset_pos->domain) && - (domainlen == 0 || namelen == domainlen || *(matchstart - 1) == '.' ) && - domainlen >= matchlen) + /* Similar algorithm to search_servers. */ + struct ipsets *ipset_pos; + unsigned int namelen = strlen(daemon->namebuff); + unsigned int matchlen = 0; + for (ipset_pos = daemon->ipsets; ipset_pos; ipset_pos = ipset_pos->next) { - matchlen = domainlen; - sets = ipset_pos->sets; + unsigned int domainlen = strlen(ipset_pos->domain); + char *matchstart = daemon->namebuff + namelen - domainlen; + if (namelen >= domainlen && hostname_isequal(matchstart, ipset_pos->domain) && + (domainlen == 0 || namelen == domainlen || *(matchstart - 1) == '.' ) && + domainlen >= matchlen) + { + matchlen = domainlen; + sets = ipset_pos->sets; + } } } #endif |