mirror of
http://thekelleys.org.uk/git/dnsmasq.git
synced 2026-11-06 15:51:41 +00:00
Compare commits
6
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e4d0bb4579 | ||
|
|
84415a87be | ||
|
|
1537645e8f | ||
|
|
ceab392c60 | ||
|
|
5f0f6aa9b1 | ||
|
|
578ea08391 |
No files matched your search
@@ -24,6 +24,10 @@ version 2.93
|
|||||||
accepts a signed CNAME reply to a DS query as proof that no DS
|
accepts a signed CNAME reply to a DS query as proof that no DS
|
||||||
exists at the domain. This fixes the DS/zone break detection logic.
|
exists at the domain. This fixes the DS/zone break detection logic.
|
||||||
|
|
||||||
|
Fix regression in 2.92 release which broke DHCPv6 when a DHCP
|
||||||
|
relay is in use. Many thanks to Jørgen Søvik for help
|
||||||
|
finding this bug.
|
||||||
|
|
||||||
|
|
||||||
version 2.92
|
version 2.92
|
||||||
Redesign the interaction between DNSSEC validation and per-domain
|
Redesign the interaction between DNSSEC validation and per-domain
|
||||||
|
|||||||
+146
-102
@@ -17,13 +17,16 @@
|
|||||||
#include "dnsmasq.h"
|
#include "dnsmasq.h"
|
||||||
|
|
||||||
static struct crec *cache_head = NULL, *cache_tail = NULL, **hash_table = NULL;
|
static struct crec *cache_head = NULL, *cache_tail = NULL, **hash_table = NULL;
|
||||||
#ifdef HAVE_DHCP
|
static struct crec *config_spare = NULL;
|
||||||
static struct crec *dhcp_spare = NULL;
|
|
||||||
#endif
|
|
||||||
static struct crec *new_chain = NULL;
|
static struct crec *new_chain = NULL;
|
||||||
static int insert_error;
|
static int insert_error;
|
||||||
static union bigname *big_free = NULL;
|
static union bigname *big_free = NULL;
|
||||||
static int bignames_left, hash_size;
|
static int bignames_left, hash_size;
|
||||||
|
struct nameblock {
|
||||||
|
struct nameblock *next;
|
||||||
|
unsigned int last, index;
|
||||||
|
char data[NAMEBLOCK_CHARS];
|
||||||
|
} *hostblocks = NULL;
|
||||||
|
|
||||||
static void make_non_terminals(struct crec *source);
|
static void make_non_terminals(struct crec *source);
|
||||||
static struct crec *really_insert(char *name, union all_addr *addr, unsigned short class,
|
static struct crec *really_insert(char *name, union all_addr *addr, unsigned short class,
|
||||||
@@ -192,6 +195,61 @@ void cache_init(void)
|
|||||||
rehash(daemon->cachesize);
|
rehash(daemon->cachesize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static struct crec *get_config_crec(void)
|
||||||
|
{
|
||||||
|
struct crec *ret;
|
||||||
|
|
||||||
|
if (config_spare)
|
||||||
|
{
|
||||||
|
ret = config_spare;
|
||||||
|
config_spare = config_spare->next;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
ret = whine_malloc(SIZEOF_POINTER_CREC);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void free_config_crec(struct crec *p)
|
||||||
|
{
|
||||||
|
p->next = config_spare;
|
||||||
|
config_spare = p;
|
||||||
|
}
|
||||||
|
|
||||||
|
static char *store_name(unsigned int namelen, unsigned int index)
|
||||||
|
{
|
||||||
|
struct nameblock *block;
|
||||||
|
char *ret = NULL;
|
||||||
|
|
||||||
|
for (block = hostblocks; block; block = block->next)
|
||||||
|
if (block->index == index && NAMEBLOCK_CHARS - block->last >= namelen)
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (!block && ((block = whine_malloc(sizeof(struct nameblock)))))
|
||||||
|
{
|
||||||
|
block->next = hostblocks;
|
||||||
|
block->index = index;
|
||||||
|
hostblocks = block;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (block && NAMEBLOCK_CHARS - block->last >= namelen)
|
||||||
|
{
|
||||||
|
ret = &block->data[block->last];
|
||||||
|
block->last += namelen;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void free_names(unsigned int index)
|
||||||
|
{
|
||||||
|
struct nameblock *block;
|
||||||
|
|
||||||
|
for (block = hostblocks; block; block = block->next)
|
||||||
|
if (index == UID_NONE || block->index == index)
|
||||||
|
block->last = 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* In most cases, we create the hash table once here by calling this with (hash_table == NULL)
|
/* In most cases, we create the hash table once here by calling this with (hash_table == NULL)
|
||||||
but if the hosts file(s) are big (some people have 50000 ad-block entries), the table
|
but if the hosts file(s) are big (some people have 50000 ad-block entries), the table
|
||||||
will be much too small, so the hosts reading code calls rehash every 1000 addresses, to
|
will be much too small, so the hosts reading code calls rehash every 1000 addresses, to
|
||||||
@@ -441,12 +499,14 @@ unsigned int cache_remove_uid(const unsigned int uid)
|
|||||||
if ((crecp->flags & (F_HOSTS | F_DHCP | F_CONFIG)) && crecp->uid == uid)
|
if ((crecp->flags & (F_HOSTS | F_DHCP | F_CONFIG)) && crecp->uid == uid)
|
||||||
{
|
{
|
||||||
*up = tmp;
|
*up = tmp;
|
||||||
free(crecp);
|
free_config_crec(crecp);
|
||||||
removed++;
|
removed++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
up = &crecp->hash_next;
|
up = &crecp->hash_next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
free_names(uid);
|
||||||
|
|
||||||
return removed;
|
return removed;
|
||||||
}
|
}
|
||||||
@@ -1261,7 +1321,7 @@ static void add_hosts_entry(struct crec *cache, union all_addr *addr, int addrle
|
|||||||
while ((lookup = cache_find_by_name(lookup, cache_get_name(cache), 0, cache->flags & (F_IPV4 | F_IPV6))))
|
while ((lookup = cache_find_by_name(lookup, cache_get_name(cache), 0, cache->flags & (F_IPV4 | F_IPV6))))
|
||||||
if ((lookup->flags & F_HOSTS) && memcmp(&lookup->addr, addr, addrlen) == 0)
|
if ((lookup->flags & F_HOSTS) && memcmp(&lookup->addr, addr, addrlen) == 0)
|
||||||
{
|
{
|
||||||
free(cache);
|
free_config_crec(cache);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1384,13 +1444,13 @@ int read_hostsfile(char *filename, unsigned int index, int cache_size, struct cr
|
|||||||
{
|
{
|
||||||
if (inet_pton(AF_INET, token, &addr) > 0)
|
if (inet_pton(AF_INET, token, &addr) > 0)
|
||||||
{
|
{
|
||||||
flags = F_HOSTS | F_IMMORTAL | F_FORWARD | F_REVERSE | F_IPV4;
|
flags = F_NAMEP | F_HOSTS | F_IMMORTAL | F_FORWARD | F_REVERSE | F_IPV4;
|
||||||
addrlen = INADDRSZ;
|
addrlen = INADDRSZ;
|
||||||
domain_suffix = get_domain(addr.addr4);
|
domain_suffix = get_domain(addr.addr4);
|
||||||
}
|
}
|
||||||
else if (inet_pton(AF_INET6, token, &addr) > 0)
|
else if (inet_pton(AF_INET6, token, &addr) > 0)
|
||||||
{
|
{
|
||||||
flags = F_HOSTS | F_IMMORTAL | F_FORWARD | F_REVERSE | F_IPV6;
|
flags = F_NAMEP | F_HOSTS | F_IMMORTAL | F_FORWARD | F_REVERSE | F_IPV6;
|
||||||
addrlen = IN6ADDRSZ;
|
addrlen = IN6ADDRSZ;
|
||||||
domain_suffix = get_domain6(&addr.addr6);
|
domain_suffix = get_domain6(&addr.addr6);
|
||||||
}
|
}
|
||||||
@@ -1424,27 +1484,37 @@ int read_hostsfile(char *filename, unsigned int index, int cache_size, struct cr
|
|||||||
if ((canon = canonicalise(token, &nomem)))
|
if ((canon = canonicalise(token, &nomem)))
|
||||||
{
|
{
|
||||||
/* If set, add a version of the name with a default domain appended */
|
/* If set, add a version of the name with a default domain appended */
|
||||||
if (option_bool(OPT_EXPAND) && domain_suffix && !fqdn &&
|
if (option_bool(OPT_EXPAND) && domain_suffix && !fqdn && (cache = get_config_crec()))
|
||||||
(cache = whine_malloc(SIZEOF_BARE_CREC + strlen(canon) + 2 + strlen(domain_suffix))))
|
|
||||||
{
|
{
|
||||||
strcpy(cache->name.sname, canon);
|
if (!(cache->name.namep = store_name(strlen(canon) + 2 + strlen(domain_suffix), index)))
|
||||||
strcat(cache->name.sname, ".");
|
free_config_crec(cache);
|
||||||
strcat(cache->name.sname, domain_suffix);
|
else
|
||||||
cache->flags = flags;
|
{
|
||||||
cache->ttd = daemon->local_ttl;
|
strcpy(cache->name.namep, canon);
|
||||||
add_hosts_entry(cache, &addr, addrlen, index, rhash, hashsz);
|
strcat(cache->name.namep, ".");
|
||||||
name_count++;
|
strcat(cache->name.namep, domain_suffix);
|
||||||
names_done++;
|
cache->flags = flags;
|
||||||
|
cache->ttd = daemon->local_ttl;
|
||||||
|
add_hosts_entry(cache, &addr, addrlen, index, rhash, hashsz);
|
||||||
|
name_count++;
|
||||||
|
names_done++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if ((cache = whine_malloc(SIZEOF_BARE_CREC + strlen(canon) + 1)))
|
if ((cache = get_config_crec()))
|
||||||
{
|
{
|
||||||
strcpy(cache->name.sname, canon);
|
if (!(cache->name.namep = store_name(strlen(canon) + 1, index)))
|
||||||
cache->flags = flags;
|
free_config_crec(cache);
|
||||||
cache->ttd = daemon->local_ttl;
|
else
|
||||||
add_hosts_entry(cache, &addr, addrlen, index, rhash, hashsz);
|
{
|
||||||
name_count++;
|
strcpy(cache->name.namep, canon);
|
||||||
names_done++;
|
cache->flags = flags;
|
||||||
|
cache->ttd = daemon->local_ttl;
|
||||||
|
add_hosts_entry(cache, &addr, addrlen, index, rhash, hashsz);
|
||||||
|
name_count++;
|
||||||
|
names_done++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
free(canon);
|
free(canon);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1495,7 +1565,7 @@ void cache_reload(void)
|
|||||||
if (cache->flags & (F_HOSTS | F_CONFIG))
|
if (cache->flags & (F_HOSTS | F_CONFIG))
|
||||||
{
|
{
|
||||||
*up = cache->hash_next;
|
*up = cache->hash_next;
|
||||||
free(cache);
|
free_config_crec(cache);
|
||||||
}
|
}
|
||||||
else if (!(cache->flags & F_DHCP))
|
else if (!(cache->flags & F_DHCP))
|
||||||
{
|
{
|
||||||
@@ -1510,11 +1580,13 @@ void cache_reload(void)
|
|||||||
else
|
else
|
||||||
up = &cache->hash_next;
|
up = &cache->hash_next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
free_names(UID_NONE); /* free everything */
|
||||||
|
|
||||||
/* Add locally-configured CNAMEs to the cache */
|
/* Add locally-configured CNAMEs to the cache */
|
||||||
for (a = daemon->cnames; a; a = a->next)
|
for (a = daemon->cnames; a; a = a->next)
|
||||||
if (a->alias[1] != '*' &&
|
if (a->alias[1] != '*' &&
|
||||||
((cache = whine_malloc(SIZEOF_POINTER_CREC))))
|
((cache = get_config_crec())))
|
||||||
{
|
{
|
||||||
cache->flags = F_FORWARD | F_NAMEP | F_CNAME | F_IMMORTAL | F_CONFIG;
|
cache->flags = F_FORWARD | F_NAMEP | F_CNAME | F_IMMORTAL | F_CONFIG;
|
||||||
cache->ttd = a->ttl;
|
cache->ttd = a->ttl;
|
||||||
@@ -1528,25 +1600,30 @@ void cache_reload(void)
|
|||||||
|
|
||||||
#ifdef HAVE_DNSSEC
|
#ifdef HAVE_DNSSEC
|
||||||
for (ds = daemon->ds; ds; ds = ds->next)
|
for (ds = daemon->ds; ds; ds = ds->next)
|
||||||
if ((cache = whine_malloc(SIZEOF_POINTER_CREC)) &&
|
if ((cache = get_config_crec()))
|
||||||
(cache->addr.ds.keydata = blockdata_alloc(ds->digest, ds->digestlen)))
|
|
||||||
{
|
{
|
||||||
cache->flags = F_FORWARD | F_IMMORTAL | F_DS | F_CONFIG | F_NAMEP;
|
|
||||||
cache->ttd = daemon->local_ttl;
|
|
||||||
cache->name.namep = ds->name;
|
|
||||||
cache->uid = ds->class;
|
|
||||||
if (ds->digestlen != 0)
|
|
||||||
{
|
|
||||||
cache->addr.ds.keylen = ds->digestlen;
|
|
||||||
cache->addr.ds.algo = ds->algo;
|
|
||||||
cache->addr.ds.keytag = ds->keytag;
|
|
||||||
cache->addr.ds.digest = ds->digest_type;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
cache->flags |= F_NEG | F_DNSSECOK | F_NO_RR;
|
|
||||||
|
|
||||||
cache_hash(cache);
|
if (!(cache->addr.ds.keydata = blockdata_alloc(ds->digest, ds->digestlen)))
|
||||||
make_non_terminals(cache);
|
free_config_crec(cache);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cache->flags = F_FORWARD | F_IMMORTAL | F_DS | F_CONFIG | F_NAMEP;
|
||||||
|
cache->ttd = daemon->local_ttl;
|
||||||
|
cache->name.namep = ds->name;
|
||||||
|
cache->uid = ds->class;
|
||||||
|
if (ds->digestlen != 0)
|
||||||
|
{
|
||||||
|
cache->addr.ds.keylen = ds->digestlen;
|
||||||
|
cache->addr.ds.algo = ds->algo;
|
||||||
|
cache->addr.ds.keytag = ds->keytag;
|
||||||
|
cache->addr.ds.digest = ds->digest_type;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
cache->flags |= F_NEG | F_DNSSECOK | F_NO_RR;
|
||||||
|
|
||||||
|
cache_hash(cache);
|
||||||
|
make_non_terminals(cache);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -1561,7 +1638,7 @@ void cache_reload(void)
|
|||||||
for (nl = hr->names; nl; nl = nl->next)
|
for (nl = hr->names; nl; nl = nl->next)
|
||||||
{
|
{
|
||||||
if ((hr->flags & HR_4) &&
|
if ((hr->flags & HR_4) &&
|
||||||
(cache = whine_malloc(SIZEOF_POINTER_CREC)))
|
(cache = get_config_crec()))
|
||||||
{
|
{
|
||||||
cache->name.namep = nl->name;
|
cache->name.namep = nl->name;
|
||||||
cache->ttd = hr->ttl;
|
cache->ttd = hr->ttl;
|
||||||
@@ -1570,7 +1647,7 @@ void cache_reload(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ((hr->flags & HR_6) &&
|
if ((hr->flags & HR_6) &&
|
||||||
(cache = whine_malloc(SIZEOF_POINTER_CREC)))
|
(cache = get_config_crec()))
|
||||||
{
|
{
|
||||||
cache->name.namep = nl->name;
|
cache->name.namep = nl->name;
|
||||||
cache->ttd = hr->ttl;
|
cache->ttd = hr->ttl;
|
||||||
@@ -1662,8 +1739,7 @@ void cache_unhash_dhcp(void)
|
|||||||
if (cache->flags & F_DHCP)
|
if (cache->flags & F_DHCP)
|
||||||
{
|
{
|
||||||
*up = cache->hash_next;
|
*up = cache->hash_next;
|
||||||
cache->next = dhcp_spare;
|
free_config_crec(cache);
|
||||||
dhcp_spare = cache;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
up = &cache->hash_next;
|
up = &cache->hash_next;
|
||||||
@@ -1734,12 +1810,7 @@ void cache_add_dhcp_entry(char *host_name, int prot,
|
|||||||
else
|
else
|
||||||
flags |= F_REVERSE;
|
flags |= F_REVERSE;
|
||||||
|
|
||||||
if ((crec = dhcp_spare))
|
if ((crec = get_config_crec()))
|
||||||
dhcp_spare = dhcp_spare->next;
|
|
||||||
else /* need new one */
|
|
||||||
crec = whine_malloc(SIZEOF_POINTER_CREC);
|
|
||||||
|
|
||||||
if (crec) /* malloc may fail */
|
|
||||||
{
|
{
|
||||||
crec->flags = flags | F_NAMEP | F_DHCP | F_FORWARD;
|
crec->flags = flags | F_NAMEP | F_DHCP | F_FORWARD;
|
||||||
if (ttd == 0)
|
if (ttd == 0)
|
||||||
@@ -1786,15 +1857,7 @@ static void make_non_terminals(struct crec *source)
|
|||||||
hostname_isequal(name, cache_get_name(crecp)))
|
hostname_isequal(name, cache_get_name(crecp)))
|
||||||
{
|
{
|
||||||
*up = crecp->hash_next;
|
*up = crecp->hash_next;
|
||||||
#ifdef HAVE_DHCP
|
free_config_crec(crecp);
|
||||||
if (type & F_DHCP)
|
|
||||||
{
|
|
||||||
crecp->next = dhcp_spare;
|
|
||||||
dhcp_spare = crecp;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
free(crecp);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -1827,17 +1890,7 @@ static void make_non_terminals(struct crec *source)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_DHCP
|
if ((crecp = get_config_crec()))
|
||||||
if ((source->flags & F_DHCP) && dhcp_spare)
|
|
||||||
{
|
|
||||||
crecp = dhcp_spare;
|
|
||||||
dhcp_spare = dhcp_spare->next;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
crecp = whine_malloc(SIZEOF_POINTER_CREC);
|
|
||||||
|
|
||||||
if (crecp)
|
|
||||||
{
|
{
|
||||||
crecp->flags = (source->flags | F_NAMEP) & ~(F_IPV4 | F_IPV6 | F_CNAME | F_RR | F_DNSKEY | F_DS | F_REVERSE);
|
crecp->flags = (source->flags | F_NAMEP) & ~(F_IPV4 | F_IPV6 | F_CNAME | F_RR | F_DNSKEY | F_DS | F_REVERSE);
|
||||||
if (!(crecp->flags & F_IMMORTAL))
|
if (!(crecp->flags & F_IMMORTAL))
|
||||||
@@ -2166,9 +2219,9 @@ static char *querystr(char *desc, unsigned short type)
|
|||||||
unsigned int i;
|
unsigned int i;
|
||||||
int len = 10; /* strlen("type=xxxxx") */
|
int len = 10; /* strlen("type=xxxxx") */
|
||||||
const char *types = NULL;
|
const char *types = NULL;
|
||||||
static char *buff = NULL;
|
static struct iovec buff = { NULL, 0 };
|
||||||
static int bufflen = 0;
|
char *buffp;
|
||||||
|
|
||||||
for (i = 0; i < (sizeof(typestr)/sizeof(typestr[0])); i++)
|
for (i = 0; i < (sizeof(typestr)/sizeof(typestr[0])); i++)
|
||||||
if (typestr[i].type == type)
|
if (typestr[i].type == type)
|
||||||
{
|
{
|
||||||
@@ -2183,37 +2236,28 @@ static char *querystr(char *desc, unsigned short type)
|
|||||||
len += strlen(desc);
|
len += strlen(desc);
|
||||||
}
|
}
|
||||||
len++; /* terminator */
|
len++; /* terminator */
|
||||||
|
|
||||||
if (!buff || bufflen < len)
|
|
||||||
{
|
|
||||||
if (buff)
|
|
||||||
free(buff);
|
|
||||||
else if (len < 20)
|
|
||||||
len = 20;
|
|
||||||
|
|
||||||
buff = whine_malloc(len);
|
|
||||||
bufflen = len;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (buff)
|
if (!expand_buf(&buff, len))
|
||||||
|
return "";
|
||||||
|
|
||||||
|
buffp = buff.iov_base;
|
||||||
|
|
||||||
|
if (desc)
|
||||||
{
|
{
|
||||||
if (desc)
|
if (types)
|
||||||
{
|
sprintf(buffp, "%s[%s]", desc, types);
|
||||||
if (types)
|
|
||||||
sprintf(buff, "%s[%s]", desc, types);
|
|
||||||
else
|
|
||||||
sprintf(buff, "%s[type=%d]", desc, type);
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
sprintf(buffp, "%s[type=%d]", desc, type);
|
||||||
if (types)
|
}
|
||||||
sprintf(buff, "<%s>", types);
|
else
|
||||||
else
|
{
|
||||||
sprintf(buff, "<type=%d>", type);
|
if (types)
|
||||||
}
|
sprintf(buffp, "<%s>", types);
|
||||||
|
else
|
||||||
|
sprintf(buffp, "<type=%d>", type);
|
||||||
}
|
}
|
||||||
|
|
||||||
return buff ? buff : "";
|
return buffp;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *edestr(int ede)
|
static char *edestr(int ede)
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
#define TCP_BACKLOG 32 /* kernel backlog limit for TCP connections */
|
#define TCP_BACKLOG 32 /* kernel backlog limit for TCP connections */
|
||||||
#define EDNS_PKTSZ 1232 /* default max EDNS.0 UDP packet from from /dnsflagday.net/2020 */
|
#define EDNS_PKTSZ 1232 /* default max EDNS.0 UDP packet from from /dnsflagday.net/2020 */
|
||||||
#define KEYBLOCK_LEN 40 /* choose to minimise fragmentation when storing DNSSEC keys */
|
#define KEYBLOCK_LEN 40 /* choose to minimise fragmentation when storing DNSSEC keys */
|
||||||
|
#define NAMEBLOCK_CHARS 1500 /* quantum of memory allocation for names from /etc/hosts */
|
||||||
#define DNSSEC_LIMIT_WORK 40 /* Max number of queries to validate one question */
|
#define DNSSEC_LIMIT_WORK 40 /* Max number of queries to validate one question */
|
||||||
#define DNSSEC_LIMIT_SIG_FAIL 20 /* Number of signature that can fail to validate in one answer */
|
#define DNSSEC_LIMIT_SIG_FAIL 20 /* Number of signature that can fail to validate in one answer */
|
||||||
#define DNSSEC_LIMIT_CRYPTO 200 /* max no. of crypto operations to validate one query. */
|
#define DNSSEC_LIMIT_CRYPTO 200 /* max no. of crypto operations to validate one query. */
|
||||||
|
|||||||
+4
-6
@@ -126,20 +126,18 @@ int hash_init(const struct nettle_hash *hash, void **ctxp, unsigned char **diges
|
|||||||
|
|
||||||
if (ctx_sz < hash->context_size)
|
if (ctx_sz < hash->context_size)
|
||||||
{
|
{
|
||||||
if (!(new = whine_malloc(hash->context_size)))
|
if (!(new = whine_realloc(ctx, hash->context_size)))
|
||||||
return 0;
|
return 0;
|
||||||
if (ctx)
|
|
||||||
free(ctx);
|
|
||||||
ctx = new;
|
ctx = new;
|
||||||
ctx_sz = hash->context_size;
|
ctx_sz = hash->context_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (digest_sz < hash->digest_size)
|
if (digest_sz < hash->digest_size)
|
||||||
{
|
{
|
||||||
if (!(new = whine_malloc(hash->digest_size)))
|
if (!(new = whine_realloc(digest, hash->digest_size)))
|
||||||
return 0;
|
return 0;
|
||||||
if (digest)
|
|
||||||
free(digest);
|
|
||||||
digest = new;
|
digest = new;
|
||||||
digest_sz = hash->digest_size;
|
digest_sz = hash->digest_size;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -399,7 +399,7 @@ void dhcp_packet(time_t now, int pxe_fd)
|
|||||||
if (mess->ciaddr.s_addr != 0)
|
if (mess->ciaddr.s_addr != 0)
|
||||||
dest.sin_addr = mess->ciaddr;
|
dest.sin_addr = mess->ciaddr;
|
||||||
}
|
}
|
||||||
if ((is_relay_use_source || mess->giaddr.s_addr) && !is_relay_reply)
|
else if ((is_relay_use_source || mess->giaddr.s_addr) && !is_relay_reply)
|
||||||
{
|
{
|
||||||
/* Send to BOOTP relay. */
|
/* Send to BOOTP relay. */
|
||||||
if (is_relay_use_source)
|
if (is_relay_use_source)
|
||||||
|
|||||||
+6
-4
@@ -1498,11 +1498,15 @@ void *safe_malloc(size_t size);
|
|||||||
void safe_strncpy(char *dest, const char *src, size_t size);
|
void safe_strncpy(char *dest, const char *src, size_t size);
|
||||||
void safe_pipe(int *fd, int read_noblock);
|
void safe_pipe(int *fd, int read_noblock);
|
||||||
#define whine_malloc(x) whine_malloc_real(__func__, __LINE__, (x))
|
#define whine_malloc(x) whine_malloc_real(__func__, __LINE__, (x))
|
||||||
#define whine_realloc(x, y) whine_realloc_real(__func__, __LINE__, (x), (y))
|
#define whine_realloc(x, y) whine_realloc_real(NULL, __func__, __LINE__, (x), (y))
|
||||||
|
#define expand_buf(x, y) expand_buf_real(__func__, __LINE__, (x), (y))
|
||||||
|
#define expand_workspace(x, y, z) expand_workspace_real(__func__, __LINE__, (x), (y), (z))
|
||||||
#define free(x) free_real(__func__, __LINE__, (x))
|
#define free(x) free_real(__func__, __LINE__, (x))
|
||||||
void free_real(const char *func, unsigned int line, void *ptr);
|
void free_real(const char *func, unsigned int line, void *ptr);
|
||||||
void *whine_malloc_real(const char *func, unsigned int line, size_t size);
|
void *whine_malloc_real(const char *func, unsigned int line, size_t size);
|
||||||
void *whine_realloc_real(const char *func, unsigned int line, void *ptr, size_t size);
|
void *whine_realloc_real(const char *wrapper, const char *func, unsigned int line, void *ptr, size_t size);
|
||||||
|
int expand_buf_real(const char *func, unsigned int line, struct iovec *iov, size_t size);
|
||||||
|
int expand_workspace_real(const char *func, unsigned int line, unsigned char ***wkspc, int *szp, int new);
|
||||||
int sa_len(union mysockaddr *addr);
|
int sa_len(union mysockaddr *addr);
|
||||||
int sockaddr_isequal(const union mysockaddr *s1, const union mysockaddr *s2);
|
int sockaddr_isequal(const union mysockaddr *s1, const union mysockaddr *s2);
|
||||||
int sockaddr_isnull(const union mysockaddr *s);
|
int sockaddr_isnull(const union mysockaddr *s);
|
||||||
@@ -1524,7 +1528,6 @@ int parse_hex(char *in, unsigned char *out, int maxlen,
|
|||||||
unsigned int *wildcard_mask, int *mac_type);
|
unsigned int *wildcard_mask, int *mac_type);
|
||||||
int memcmp_masked(unsigned char *a, unsigned char *b, int len,
|
int memcmp_masked(unsigned char *a, unsigned char *b, int len,
|
||||||
unsigned int mask);
|
unsigned int mask);
|
||||||
int expand_buf(struct iovec *iov, size_t size);
|
|
||||||
char *print_mac(char *buff, unsigned char *mac, int len);
|
char *print_mac(char *buff, unsigned char *mac, int len);
|
||||||
int read_write(int fd, unsigned char *packet, int size, int rw);
|
int read_write(int fd, unsigned char *packet, int size, int rw);
|
||||||
int read_writev(int fd, struct iovec *iov, int iovcnt, int rw);
|
int read_writev(int fd, struct iovec *iov, int iovcnt, int rw);
|
||||||
@@ -1916,7 +1919,6 @@ int do_poll(int timeout);
|
|||||||
/* rrfilter.c */
|
/* rrfilter.c */
|
||||||
size_t rrfilter(struct dns_header *header, size_t *plen, int mode);
|
size_t rrfilter(struct dns_header *header, size_t *plen, int mode);
|
||||||
short *rrfilter_desc(int type);
|
short *rrfilter_desc(int type);
|
||||||
int expand_workspace(unsigned char ***wkspc, int *szp, int new);
|
|
||||||
int to_wire(char *name);
|
int to_wire(char *name);
|
||||||
void from_wire(char *name);
|
void from_wire(char *name);
|
||||||
/* modes. */
|
/* modes. */
|
||||||
|
|||||||
+5
-2
@@ -23,6 +23,9 @@ static volatile int mem_recover = 0;
|
|||||||
static jmp_buf mem_jmp;
|
static jmp_buf mem_jmp;
|
||||||
static int one_file(char *file, int hard_opt);
|
static int one_file(char *file, int hard_opt);
|
||||||
|
|
||||||
|
static void *opt_malloc_real(const char *func, unsigned int line, size_t size);
|
||||||
|
#define opt_malloc(x) opt_malloc_real(__func__, __LINE__, (x))
|
||||||
|
|
||||||
/* Solaris headers don't have facility names. */
|
/* Solaris headers don't have facility names. */
|
||||||
#ifdef HAVE_SOLARIS_NETWORK
|
#ifdef HAVE_SOLARIS_NETWORK
|
||||||
static const struct {
|
static const struct {
|
||||||
@@ -655,13 +658,13 @@ static void unhide_metas(char *cp)
|
|||||||
*cp = unhide_meta(*cp);
|
*cp = unhide_meta(*cp);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *opt_malloc(size_t size)
|
static void *opt_malloc_real(const char *func, unsigned int line, size_t size)
|
||||||
{
|
{
|
||||||
void *ret;
|
void *ret;
|
||||||
|
|
||||||
if (mem_recover)
|
if (mem_recover)
|
||||||
{
|
{
|
||||||
ret = whine_malloc(size);
|
ret = whine_malloc_real(func, line, size);
|
||||||
if (!ret)
|
if (!ret)
|
||||||
longjmp(mem_jmp, 1);
|
longjmp(mem_jmp, 1);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -337,27 +337,6 @@ short *rrfilter_desc(int type)
|
|||||||
return p+1;
|
return p+1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int expand_workspace(unsigned char ***wkspc, int *szp, int new)
|
|
||||||
{
|
|
||||||
unsigned char **p;
|
|
||||||
int old = *szp;
|
|
||||||
|
|
||||||
if (old >= new+1)
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
new += 5;
|
|
||||||
|
|
||||||
if (!(p = whine_realloc(*wkspc, new * sizeof(unsigned char *))))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
memset(p+old, 0, new-old);
|
|
||||||
|
|
||||||
*wkspc = p;
|
|
||||||
*szp = new;
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Convert from presentation format to wire format, in place.
|
/* Convert from presentation format to wire format, in place.
|
||||||
Also map UC -> LC.
|
Also map UC -> LC.
|
||||||
Note that using extract_name to get presentation format
|
Note that using extract_name to get presentation format
|
||||||
|
|||||||
+47
-22
@@ -672,26 +672,6 @@ int memcmp_masked(unsigned char *a, unsigned char *b, int len, unsigned int mask
|
|||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* _note_ may copy buffer */
|
|
||||||
int expand_buf(struct iovec *iov, size_t size)
|
|
||||||
{
|
|
||||||
void *new;
|
|
||||||
|
|
||||||
if (size <= (size_t)iov->iov_len)
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
if (!(new = whine_realloc(iov->iov_base, size)))
|
|
||||||
{
|
|
||||||
errno = ENOMEM;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
iov->iov_base = new;
|
|
||||||
iov->iov_len = size;
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
char *print_mac(char *buff, unsigned char *mac, int len)
|
char *print_mac(char *buff, unsigned char *mac, int len)
|
||||||
{
|
{
|
||||||
char *p = buff;
|
char *p = buff;
|
||||||
@@ -955,7 +935,7 @@ void *whine_malloc_real(const char *func, unsigned int line, size_t size)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *whine_realloc_real(const char *func, unsigned int line, void *ptr, size_t size)
|
void *whine_realloc_real(const char *wrapper, const char *func, unsigned int line, void *ptr, size_t size)
|
||||||
{
|
{
|
||||||
unsigned int old = hash_ptr(ptr);
|
unsigned int old = hash_ptr(ptr);
|
||||||
void *ret = realloc(ptr, size);
|
void *ret = realloc(ptr, size);
|
||||||
@@ -963,11 +943,56 @@ void *whine_realloc_real(const char *func, unsigned int line, void *ptr, size_t
|
|||||||
if (!ret)
|
if (!ret)
|
||||||
my_syslog(LOG_ERR, _("failed to reallocate %d bytes"), (int) size);
|
my_syslog(LOG_ERR, _("failed to reallocate %d bytes"), (int) size);
|
||||||
else if (daemon->log_malloc)
|
else if (daemon->log_malloc)
|
||||||
my_syslog(LOG_INFO, _("realloc: %s:%u %zu bytes from %x to %x"), func, line, size, old, hash_ptr(ret));
|
{
|
||||||
|
if (!wrapper)
|
||||||
|
wrapper = "realloc";
|
||||||
|
my_syslog(LOG_INFO, _("%s: %s:%u %zu bytes from %x to %x"), wrapper, func, line, size, old, hash_ptr(ret));
|
||||||
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* _note_ may copy buffer */
|
||||||
|
int expand_buf_real(const char *func, unsigned int line, struct iovec *iov, size_t size)
|
||||||
|
{
|
||||||
|
void *new;
|
||||||
|
|
||||||
|
if (size <= (size_t)iov->iov_len)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
if (!(new = whine_realloc_real("expand_buf", func, line, iov->iov_base, size)))
|
||||||
|
{
|
||||||
|
errno = ENOMEM;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
iov->iov_base = new;
|
||||||
|
iov->iov_len = size;
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int expand_workspace_real(const char *func, unsigned int line, unsigned char ***wkspc, int *szp, int new)
|
||||||
|
{
|
||||||
|
unsigned char **p;
|
||||||
|
int old = *szp;
|
||||||
|
|
||||||
|
if (old >= new+1)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
new += 5;
|
||||||
|
|
||||||
|
if (!(p = whine_realloc_real("expand_workspace", func, line, *wkspc, new * sizeof(unsigned char *))))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
memset(p+old, 0, new-old);
|
||||||
|
|
||||||
|
*wkspc = p;
|
||||||
|
*szp = new;
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
#undef free
|
#undef free
|
||||||
void free_real(const char *func, unsigned int line, void *ptr)
|
void free_real(const char *func, unsigned int line, void *ptr)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in new issue
Block a user