summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSimon Kelley <simon@thekelleys.org.uk>2014-04-13 20:48:57 +0100
committerSimon Kelley <simon@thekelleys.org.uk>2014-04-13 20:48:57 +0100
commit82a14af5e742f685149ede3f3c3aa32e7ef97d6d (patch)
treeaee555bac5bfe9b6c0b0089fc82ba2ee61bfbbaf /src
parent97dce08ed725be721ad2cc74c320e79dc9d6f895 (diff)
downloaddnsmasq-82a14af5e742f685149ede3f3c3aa32e7ef97d6d.tar.gz
Ensure request name in buffer for ipset lookup.
Diffstat (limited to 'src')
-rw-r--r--src/forward.c27
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