]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
- Fix for #1099: Fix to check for deleted RRset when the contents
authorW.C.A. Wijngaards <wouter@nlnetlabs.nl>
Fri, 5 Jul 2024 15:54:46 +0000 (17:54 +0200)
committerW.C.A. Wijngaards <wouter@nlnetlabs.nl>
Fri, 5 Jul 2024 15:54:46 +0000 (17:54 +0200)
  is updated and fetched after it is stored, and also check for a
  changed RRset.

doc/Changelog
services/cache/dns.c

index 5d195d37da3c5a11d0a1786e9d214c4f578660cd..c184ac22bbc64e9ffb46733fefe3c3436c8aafda 100644 (file)
@@ -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
index 3307f58fe0e7711231e4bd0f6a07ae22eb1996ff..ff434ed4c6c1b912073f442923333c92c7154473 100644 (file)
@@ -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;