]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Add better ZEROTTL handling in bindrdataset()
authorOndřej Surý <ondrej@isc.org>
Sun, 2 Feb 2025 12:38:04 +0000 (13:38 +0100)
committerOndřej Surý <ondrej@isc.org>
Mon, 3 Feb 2025 13:39:06 +0000 (14:39 +0100)
If we know that the header has ZEROTTL set, the server should never send
stale records for it and the TTL should never be anything else than 0.
The comment was already there, but the code was not matching the
comment.

lib/dns/qpcache.c

index 589ddd0aa118db9db5cfee478119a57defa491a3..64624453e03a920f8b36ef0041ce7b20c6b790ad 100644 (file)
@@ -1057,7 +1057,7 @@ bindrdataset(qpcache_t *qpdb, qpcnode_t *node, dns_slabheader_t *header,
                 * (these records should not be cached anyway).
                 */
 
-               if (KEEPSTALE(qpdb) && stale_ttl > now) {
+               if (!ZEROTTL(header) && KEEPSTALE(qpdb) && stale_ttl > now) {
                        stale = true;
                } else {
                        /*
@@ -1072,7 +1072,7 @@ bindrdataset(qpcache_t *qpdb, qpcnode_t *node, dns_slabheader_t *header,
        rdataset->rdclass = qpdb->common.rdclass;
        rdataset->type = DNS_TYPEPAIR_TYPE(header->type);
        rdataset->covers = DNS_TYPEPAIR_COVERS(header->type);
-       rdataset->ttl = header->expire - now;
+       rdataset->ttl = !ZEROTTL(header) ? header->expire - now : 0;
        rdataset->trust = header->trust;
        rdataset->resign = 0;