]> git.ipfire.org Git - people/ms/dnsmasq.git/commitdiff
Fix DNS failure of cachesize set to zero.
authorSimon Kelley <simon@thekelleys.org.uk>
Fri, 9 May 2014 09:29:43 +0000 (10:29 +0100)
committerSimon Kelley <simon@thekelleys.org.uk>
Fri, 9 May 2014 09:29:43 +0000 (10:29 +0100)
CHANGELOG
src/blockdata.c

index 55c33b9f5fe4ce1246e0d4de66413488c761cb30..6c3782daae1b292fccc19bb2cd1699bb98ad9e3e 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -11,6 +11,10 @@ version 2.71
            Fix DNSSEC validation of ANY queries. Thanks to Marco Davids
            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
             Fix crash, introduced in 2.69, on TCP request when dnsmasq
index 272d3a67f4ebd0b293b4f26aafaf312f3772f6c9..5a70a7967fa3c44cdf23b5cbb849e008fd44201a 100644 (file)
@@ -25,7 +25,7 @@ static void blockdata_expand(int n)
 {
   struct blockdata *new = whine_malloc(n * sizeof(struct blockdata));
   
-  if (new)
+  if (n > 0 && new)
     {
       int i;
       
@@ -46,14 +46,19 @@ void blockdata_init(void)
   blockdata_alloced = 0;
   blockdata_count = 0;
   blockdata_hwm = 0;
-  
-  blockdata_expand((daemon->cachesize * 100) / sizeof(struct blockdata));
+
+  /* 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));
 }
 
 void blockdata_report(void)
 {
-  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));
+  if (option_bool(OPT_DNSSEC_VALID))
+    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));
 } 
 
 struct blockdata *blockdata_alloc(char *data, size_t len)