mirror of
https://github.com/pi-hole/dnsmasq.git
synced 2025-12-19 18:28:25 +00:00
Fix problem with re-allocation of serverarray.
This commit is contained in:
@@ -1103,7 +1103,7 @@ extern struct daemon {
|
|||||||
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, *local_domains, **serverarray, *no_rebind;
|
struct server *servers, *local_domains, **serverarray, *no_rebind;
|
||||||
int serverarraysz;
|
int serverarraysz, serverarrayhwm;
|
||||||
struct ipsets *ipsets;
|
struct ipsets *ipsets;
|
||||||
u32 allowlist_mask;
|
u32 allowlist_mask;
|
||||||
struct allowlist *allowlists;
|
struct allowlist *allowlists;
|
||||||
|
|||||||
@@ -37,17 +37,21 @@ void build_server_array(void)
|
|||||||
for (serv = daemon->local_domains; serv; serv = serv->next)
|
for (serv = daemon->local_domains; serv; serv = serv->next)
|
||||||
count++;
|
count++;
|
||||||
|
|
||||||
if (count > daemon->serverarraysz)
|
daemon->serverarraysz = count;
|
||||||
|
|
||||||
|
if (count > daemon->serverarrayhwm)
|
||||||
{
|
{
|
||||||
struct server **new;
|
struct server **new;
|
||||||
|
|
||||||
|
count += 10; /* A few extra without re-allocating. */
|
||||||
|
|
||||||
if ((new = whine_malloc(count * sizeof(struct server *))))
|
if ((new = whine_malloc(count * sizeof(struct server *))))
|
||||||
{
|
{
|
||||||
if (daemon->serverarray)
|
if (daemon->serverarray)
|
||||||
free(daemon->serverarray);
|
free(daemon->serverarray);
|
||||||
|
|
||||||
daemon->serverarray = new;
|
daemon->serverarray = new;
|
||||||
daemon->serverarraysz = count;
|
daemon->serverarrayhwm = count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -935,7 +935,6 @@ char *parse_server(char *arg, union mysockaddr *addr, union mysockaddr *source_a
|
|||||||
static int domain_rev4(char *domain, struct in_addr addr, int msize)
|
static int domain_rev4(char *domain, struct in_addr addr, int msize)
|
||||||
{
|
{
|
||||||
in_addr_t a = ntohl(addr.s_addr);
|
in_addr_t a = ntohl(addr.s_addr);
|
||||||
char *p;
|
|
||||||
|
|
||||||
*domain = 0;
|
*domain = 0;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user