]> rtime.felk.cvut.cz Git - pes-rpp/rpp-lwip.git/commitdiff
Fixed bug #36899 DNS TTL 0 is cached for a long time
authorgoldsimon <goldsimon@gmx.de>
Mon, 13 Aug 2012 19:32:44 +0000 (21:32 +0200)
committergoldsimon <goldsimon@gmx.de>
Mon, 13 Aug 2012 19:32:44 +0000 (21:32 +0200)
CHANGELOG
src/core/dns.c

index dbed662eccea788c2f7386c7ac758d1bcae49af0..197f1e04823a0dc9d979aeebcfc1764b4f6226b7 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -80,6 +80,9 @@ HISTORY
 
  ++ Bugfixes:
 
+  2012-08-13: Simon Goldschmidt
+  * dns.c: fixed bug #36899 DNS TTL 0 is cached for a long time
+
   2012-05-11: Simon Goldschmidt (patch by Marty)
   * memp.c: fixed bug #36412: memp.c does not compile when
     MEMP_OVERFLOW_CHECK > zero and MEMP_SEPARATE_POOLS == 1
index d63361226f2e793478f71798bbc6bf7aa074a1a4..788df7155d502a7f68edbc282ced854e710ddc0a 100644 (file)
@@ -694,7 +694,7 @@ dns_check_entry(u8_t i)
 
     case DNS_STATE_DONE: {
       /* if the time to live is nul */
-      if (--pEntry->ttl == 0) {
+      if ((pEntry->ttl == 0) || (--pEntry->ttl == 0)) {
         LWIP_DEBUGF(DNS_DEBUG, ("dns_check_entry: \"%s\": flush\n", pEntry->name));
         /* flush this entry */
         pEntry->state = DNS_STATE_UNUSED;
@@ -816,6 +816,13 @@ dns_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, ip_addr_t *addr, u16_t
             if (pEntry->found) {
               (*pEntry->found)(pEntry->name, &pEntry->ipaddr, pEntry->arg);
             }
+            if (pEntry->ttl == 0) {
+              /* RFC 883, page 29: "Zero values are
+                 interpreted to mean that the RR can only be used for the
+                 transaction in progress, and should not be cached."
+                 -> flush this entry now */
+              goto flushentry;
+            }
             /* deallocate memory and return */
             goto memerr;
           } else {
@@ -838,6 +845,7 @@ responseerr:
   if (pEntry->found) {
     (*pEntry->found)(pEntry->name, NULL, pEntry->arg);
   }
+flushentry:
   /* flush this entry */
   pEntry->state = DNS_STATE_UNUSED;
   pEntry->found = NULL;