Fix DNS failure of cachesize set to zero.

This commit is contained in:
Simon Kelley
2014-05-09 10:29:43 +01:00
parent 8aa999ef69
commit b692f23466
2 changed files with 14 additions and 5 deletions

View File

@@ -11,6 +11,10 @@ version 2.71
Fix DNSSEC validation of ANY queries. Thanks to Marco Davids Fix DNSSEC validation of ANY queries. Thanks to Marco Davids
for spotting that too. for spotting that too.
Fix total DNS failure and 100% CPU use if cachesize set to zero,
regression introduced in 2.69. Thanks to James Hunt and
the Ubuntu crowd for assistance in fixing this.
version 2.70 version 2.70
Fix crash, introduced in 2.69, on TCP request when dnsmasq Fix crash, introduced in 2.69, on TCP request when dnsmasq

View File

@@ -25,7 +25,7 @@ static void blockdata_expand(int n)
{ {
struct blockdata *new = whine_malloc(n * sizeof(struct blockdata)); struct blockdata *new = whine_malloc(n * sizeof(struct blockdata));
if (new) if (n > 0 && new)
{ {
int i; int i;
@@ -47,13 +47,18 @@ void blockdata_init(void)
blockdata_count = 0; blockdata_count = 0;
blockdata_hwm = 0; blockdata_hwm = 0;
/* Note that daemon->cachesize is enforced to have non-zero size if OPT_DNSSEC_VALID is set */
if (option_bool(OPT_DNSSEC_VALID))
blockdata_expand((daemon->cachesize * 100) / sizeof(struct blockdata)); blockdata_expand((daemon->cachesize * 100) / sizeof(struct blockdata));
} }
void blockdata_report(void) void blockdata_report(void)
{ {
if (option_bool(OPT_DNSSEC_VALID))
my_syslog(LOG_INFO, _("DNSSEC memory in use %u, max %u, allocated %u"), my_syslog(LOG_INFO, _("DNSSEC memory in use %u, max %u, allocated %u"),
blockdata_count * sizeof(struct blockdata), blockdata_hwm * sizeof(struct blockdata), blockdata_alloced * sizeof(struct blockdata)); blockdata_count * sizeof(struct blockdata),
blockdata_hwm * sizeof(struct blockdata),
blockdata_alloced * sizeof(struct blockdata));
} }
struct blockdata *blockdata_alloc(char *data, size_t len) struct blockdata *blockdata_alloc(char *data, size_t len)