From: W.C.A. Wijngaards Date: Fri, 5 Jul 2024 15:54:46 +0000 (+0200) Subject: - Fix for #1099: Fix to check for deleted RRset when the contents X-Git-Tag: release-1.21.0rc1~38 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c8a228954278d9dcf99b96920d19bc5861b1ae20;p=thirdparty%2Funbound.git - Fix for #1099: Fix to check for deleted RRset when the contents is updated and fetched after it is stored, and also check for a changed RRset. --- diff --git a/doc/Changelog b/doc/Changelog index 5d195d37d..c184ac22b 100644 --- a/doc/Changelog +++ b/doc/Changelog @@ -2,6 +2,9 @@ - Fix for neater printout for error for missing DS response. - Fix neater printout. - Fix #1099: Unbound core dump on SIGSEGV. + - Fix for #1099: Fix to check for deleted RRset when the contents + is updated and fetched after it is stored, and also check for a + changed RRset. 4 July 2024: Wouter - Fix to print details about the failure to lookup a DNSKEY record diff --git a/services/cache/dns.c b/services/cache/dns.c index 3307f58fe..ff434ed4c 100644 --- a/services/cache/dns.c +++ b/services/cache/dns.c @@ -96,7 +96,8 @@ store_rrsets(struct module_env* env, struct reply_info* rep, time_t now, struct ub_packed_rrset_key* ck; lock_rw_rdlock(&rep->ref[i].key->entry.lock); /* if deleted rrset, do not copy it */ - if(rep->ref[i].key->id == 0) + if(rep->ref[i].key->id == 0 || + rep->ref[i].id != rep->ref[i].key->id) ck = NULL; else ck = packed_rrset_copy_region( rep->ref[i].key, region, now); @@ -115,10 +116,14 @@ store_rrsets(struct module_env* env, struct reply_info* rep, time_t now, } /* if ref was updated make sure the message ttl is updated to * the minimum of the current rrsets. */ - lock_rw_rdlock(&rep->rrsets[i]->entry.lock); - ttl = ((struct packed_rrset_data*)rep->rrsets[i]->entry.data)->ttl; - lock_rw_unlock(&rep->rrsets[i]->entry.lock); - if(ttl < min_ttl) min_ttl = ttl; + lock_rw_rdlock(&rep->ref[i].key->entry.lock); + if(rep->ref[i].key->id != 0 && + rep->ref[i].id == rep->ref[i].key->id) { + /* if deleted, skip ttl update. */ + ttl = ((struct packed_rrset_data*)rep->rrsets[i]->entry.data)->ttl; + if(ttl < min_ttl) min_ttl = ttl; + } + lock_rw_unlock(&rep->ref[i].key->entry.lock); } if(min_ttl < rep->ttl) { rep->ttl = min_ttl;