diff --git a/CHANGELOG b/CHANGELOG index dbed662e..197f1e04 100644 --- 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 diff --git a/src/core/dns.c b/src/core/dns.c index d6336122..788df715 100644 --- a/src/core/dns.c +++ b/src/core/dns.c @@ -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;