Skip to content

Commit

Permalink
- Fix for #1099: Fix to check for deleted RRset when the contents
Browse files Browse the repository at this point in the history
  is updated and fetched after it is stored, and also check for a
  changed RRset.
  • Loading branch information
wcawijngaards committed Jul 5, 2024
1 parent b53d900 commit c8a2289
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
3 changes: 3 additions & 0 deletions doc/Changelog
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 10 additions & 5 deletions services/cache/dns.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
Expand Down

0 comments on commit c8a2289

Please sign in to comment.