summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Kelley <simon@thekelleys.org.uk>2021-09-24 15:25:05 +0100
committerSimon Kelley <simon@thekelleys.org.uk>2021-09-24 15:25:05 +0100
commit981fb037102306a4ca683f14c8469db4d5e27233 (patch)
treeb8be7c9f9738013e3afd899a33c80e0946605eec
parentef2f8d70d22b817e1faf96efd42c61879e25c723 (diff)
downloaddnsmasq-981fb037102306a4ca683f14c8469db4d5e27233.tar.gz
Make --rebind-domain-ok work with IDN.
-rw-r--r--src/dnsmasq.h8
-rw-r--r--src/forward.c8
-rw-r--r--src/option.c7
3 files changed, 14 insertions, 9 deletions
diff --git a/src/dnsmasq.h b/src/dnsmasq.h
index 639c568..1a66e9b 100644
--- a/src/dnsmasq.h
+++ b/src/dnsmasq.h
@@ -609,6 +609,11 @@ struct serv_local {
struct server *next;
};
+struct rebind_domain {
+ char *domain;
+ struct rebind_domain *next;
+};
+
struct ipsets {
char **sets;
char *domain;
@@ -1105,7 +1110,8 @@ extern struct daemon {
char *lease_change_command;
struct iname *if_names, *if_addrs, *if_except, *dhcp_except, *auth_peers, *tftp_interfaces;
struct bogus_addr *bogus_addr, *ignore_addr;
- struct server *servers, *servers_tail, *local_domains, **serverarray, *no_rebind;
+ struct server *servers, *servers_tail, *local_domains, **serverarray;
+ struct rebind_domain *no_rebind;
int server_has_wildcard;
int serverarraysz, serverarrayhwm;
struct ipsets *ipsets;
diff --git a/src/forward.c b/src/forward.c
index 786b11f..e74e396 100644
--- a/src/forward.c
+++ b/src/forward.c
@@ -151,11 +151,11 @@ static void server_send_log(struct server *server, int fd,
static int domain_no_rebind(char *domain)
{
- struct server *serv;
- int dlen = (int)strlen(domain);
+ struct rebind_domain *rbd;
+ size_t tlen, dlen = strlen(domain);
- for (serv = daemon->no_rebind; serv; serv = serv->next)
- if (dlen >= serv->domain_len && strcmp(serv->domain, &domain[dlen - serv->domain_len]) == 0)
+ for (rbd = daemon->no_rebind; rbd; rbd = rbd->next)
+ if (dlen >= (tlen = strlen(rbd->domain)) && strcmp(rbd->domain, &domain[dlen - tlen]) == 0)
return 1;
return 0;
diff --git a/src/option.c b/src/option.c
index 54d89aa..5402170 100644
--- a/src/option.c
+++ b/src/option.c
@@ -2715,7 +2715,7 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
case LOPT_NO_REBIND: /* --rebind-domain-ok */
{
- struct server *new;
+ struct rebind_domain *new;
unhide_metas(arg);
@@ -2724,9 +2724,8 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
do {
comma = split_chr(arg, '/');
- new = opt_malloc(sizeof(struct serv_local));
- new->domain = opt_string_alloc(arg);
- new->domain_len = strlen(arg);
+ new = opt_malloc(sizeof(struct rebind_domain));
+ new->domain = canonicalise_opt(arg);
new->next = daemon->no_rebind;
daemon->no_rebind = new;
arg = comma;