From: Yorgos Thessalonikefs Date: Fri, 12 Sep 2025 13:24:06 +0000 (+0200) Subject: Merge branch 'master' into features/no-ttl-zero-cacherep X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d521135f667e30e9e099e6971364537ba9d8247a;p=thirdparty%2Funbound.git Merge branch 'master' into features/no-ttl-zero-cacherep --- d521135f667e30e9e099e6971364537ba9d8247a diff --cc util/data/msgencode.c index 3129018db,84aa3b9e7..b389800d0 --- a/util/data/msgencode.c +++ b/util/data/msgencode.c @@@ -1021,18 -1021,7 +1021,18 @@@ reply_info_answer_encode(struct query_i flags |= BIT_AA; flags &= ~BIT_AD; } - log_assert(flags & BIT_QR); /* QR bit must be on in our replies */ + log_assert((flags & BIT_QR)); /* QR bit must be on in our replies */ + if(cached_ttl && rep->ttl - timenow == 0) { + /* The last remaining second of the TTL for a cached response + * is replied. This makes a 0 in the protocol message. The + * response is valid for the cache, but the DNS TTL 0 item + * causes the received to drop the contents. Even though the + * contents are cachable, so the time used is decremented + * to change that into 1 second, and it can be cached, and + * used for expired response generation, and does not give + * repeated queries during that last second. */ + timenow --; + } if(udpsize < LDNS_HEADER_SIZE) return 0; /* currently edns does not change during calculations;