Make --rebind-domain-ok work with IDN.

This commit is contained in:
Simon Kelley
2021-09-24 15:25:05 +01:00
parent ef2f8d70d2
commit 981fb03710
3 changed files with 14 additions and 9 deletions

View File

@@ -609,6 +609,11 @@ struct serv_local {
struct server *next; struct server *next;
}; };
struct rebind_domain {
char *domain;
struct rebind_domain *next;
};
struct ipsets { struct ipsets {
char **sets; char **sets;
char *domain; char *domain;
@@ -1105,7 +1110,8 @@ extern struct daemon {
char *lease_change_command; char *lease_change_command;
struct iname *if_names, *if_addrs, *if_except, *dhcp_except, *auth_peers, *tftp_interfaces; struct iname *if_names, *if_addrs, *if_except, *dhcp_except, *auth_peers, *tftp_interfaces;
struct bogus_addr *bogus_addr, *ignore_addr; 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 server_has_wildcard;
int serverarraysz, serverarrayhwm; int serverarraysz, serverarrayhwm;
struct ipsets *ipsets; struct ipsets *ipsets;

View File

@@ -151,11 +151,11 @@ static void server_send_log(struct server *server, int fd,
static int domain_no_rebind(char *domain) static int domain_no_rebind(char *domain)
{ {
struct server *serv; struct rebind_domain *rbd;
int dlen = (int)strlen(domain); size_t tlen, dlen = strlen(domain);
for (serv = daemon->no_rebind; serv; serv = serv->next) for (rbd = daemon->no_rebind; rbd; rbd = rbd->next)
if (dlen >= serv->domain_len && strcmp(serv->domain, &domain[dlen - serv->domain_len]) == 0) if (dlen >= (tlen = strlen(rbd->domain)) && strcmp(rbd->domain, &domain[dlen - tlen]) == 0)
return 1; return 1;
return 0; return 0;

View File

@@ -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 */ case LOPT_NO_REBIND: /* --rebind-domain-ok */
{ {
struct server *new; struct rebind_domain *new;
unhide_metas(arg); unhide_metas(arg);
@@ -2724,9 +2724,8 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
do { do {
comma = split_chr(arg, '/'); comma = split_chr(arg, '/');
new = opt_malloc(sizeof(struct serv_local)); new = opt_malloc(sizeof(struct rebind_domain));
new->domain = opt_string_alloc(arg); new->domain = canonicalise_opt(arg);
new->domain_len = strlen(arg);
new->next = daemon->no_rebind; new->next = daemon->no_rebind;
daemon->no_rebind = new; daemon->no_rebind = new;
arg = comma; arg = comma;