diff options
author | Simon Kelley <simon@thekelleys.org.uk> | 2021-06-26 21:13:41 +0100 |
---|---|---|
committer | Simon Kelley <simon@thekelleys.org.uk> | 2021-06-26 21:13:41 +0100 |
commit | 66b863c989db740d65612454aa0f8e47f18d6874 (patch) | |
tree | 501a1bd059312f7f85e99f46cc296a854d117554 | |
parent | c9efe8e5e11817a31107a053eb09d827783c62fd (diff) | |
download | dnsmasq-2.86test4.tar.gz |
Fix problem with re-allocation of serverarray.v2.86test4
-rw-r--r-- | src/dnsmasq.h | 2 | ||||
-rw-r--r-- | src/domain-match.c | 10 | ||||
-rw-r--r-- | src/option.c | 3 |
3 files changed, 9 insertions, 6 deletions
diff --git a/src/dnsmasq.h b/src/dnsmasq.h index eeacd16..939e41e 100644 --- a/src/dnsmasq.h +++ b/src/dnsmasq.h @@ -1103,7 +1103,7 @@ extern struct daemon { struct iname *if_names, *if_addrs, *if_except, *dhcp_except, *auth_peers, *tftp_interfaces; struct bogus_addr *bogus_addr, *ignore_addr; struct server *servers, *local_domains, **serverarray, *no_rebind; - int serverarraysz; + int serverarraysz, serverarrayhwm; struct ipsets *ipsets; u32 allowlist_mask; struct allowlist *allowlists; diff --git a/src/domain-match.c b/src/domain-match.c index 473d0b2..4242d0a 100644 --- a/src/domain-match.c +++ b/src/domain-match.c @@ -36,18 +36,22 @@ void build_server_array(void) for (serv = daemon->local_domains; serv; serv = serv->next) count++; - - if (count > daemon->serverarraysz) + + daemon->serverarraysz = count; + + if (count > daemon->serverarrayhwm) { struct server **new; + count += 10; /* A few extra without re-allocating. */ + if ((new = whine_malloc(count * sizeof(struct server *)))) { if (daemon->serverarray) free(daemon->serverarray); daemon->serverarray = new; - daemon->serverarraysz = count; + daemon->serverarrayhwm = count; } } diff --git a/src/option.c b/src/option.c index b631482..97d49be 100644 --- a/src/option.c +++ b/src/option.c @@ -935,8 +935,7 @@ char *parse_server(char *arg, union mysockaddr *addr, union mysockaddr *source_a static int domain_rev4(char *domain, struct in_addr addr, int msize) { in_addr_t a = ntohl(addr.s_addr); - char *p; - + *domain = 0; switch (msize) |