]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
fixup nasty cache overwriting bug.
authorWouter Wijngaards <wouter@nlnetlabs.nl>
Wed, 3 Oct 2007 19:11:50 +0000 (19:11 +0000)
committerWouter Wijngaards <wouter@nlnetlabs.nl>
Wed, 3 Oct 2007 19:11:50 +0000 (19:11 +0000)
git-svn-id: file:///svn/unbound/trunk@656 be551aaa-1e26-0410-a405-d3ace91eadb9

doc/Changelog
services/cache/rrset.c
util/data/msgreply.c

index 138fc0f191da5c0aee727e3f290f0399d828d0a2..739b61202c1464208d4926ece19afa072accef07 100644 (file)
@@ -7,6 +7,8 @@
          number with parse errors.
        - unit test for multiple ENT case.
        - fix for cname out of validated unsec zone.
+       - fixup nasty id=0 reuse. Also added assertions to detect its
+         return (the assertion catches in the existing test cases).
 
 1 October 2007: Wouter
        - skip F77, CXX, objC tests in configure step.
index 628a9e63104d446cb8d001389bbaef02c549900e..431a660b9a3f47fefea357b0e08d7ad347c2114c 100644 (file)
@@ -177,6 +177,7 @@ rrset_cache_update(struct rrset_cache* r, struct rrset_ref* ref,
        hashvalue_t h = k->entry.hash;
        uint16_t rrset_type = ntohs(k->rk.type);
        int equal = 0;
+       log_assert(ref->id != 0 && k->id != 0);
        /* looks up item with a readlock - no editing! */
        if((e=slabhash_lookup(&r->table, h, k, 0)) != 0) {
                /* return id and key as they will be used in the cache
@@ -206,6 +207,7 @@ rrset_cache_update(struct rrset_cache* r, struct rrset_ref* ref,
                /* use insert to update entry to manage lruhash
                 * cache size values nicely. */
        }
+       log_assert(ref->key->id != 0);
        slabhash_insert(&r->table, h, &k->entry, k->entry.data, alloc);
        if(e) {
                /* For NSEC, NSEC3, DNAME, when rdata is updated, update 
@@ -261,6 +263,7 @@ rrset_array_lock(struct rrset_ref* ref, size_t count, uint32_t timenow)
                if(i>0 && ref[i].key == ref[i-1].key)
                        continue; /* only lock items once */
                lock_rw_rdlock(&ref[i].key->entry.lock);
+               log_assert(ref[i].id != 0 && ref[i].key->id != 0);
                if(ref[i].id != ref[i].key->id || timenow >
                        ((struct packed_rrset_data*)(ref[i].key->entry.data))
                        ->ttl) {
index ef72d5fd9e15ad3c63310924a2a625eac605242f..91f9256afa11c3d76850c5d9efb6a04a59ffbe85 100644 (file)
@@ -596,13 +596,13 @@ repinfo_copy_rrsets(struct reply_info* dest, struct reply_info* from,
                fk = from->rrsets[i];
                dk = dest->rrsets[i];
                fd = (struct packed_rrset_data*)fk->entry.data;
-               dk->id = fk->id;
                dk->entry.hash = fk->entry.hash;
                dk->rk = fk->rk;
-               if(region)
+               if(region) {
+                       dk->id = fk->id;
                        dk->rk.dname = (uint8_t*)region_alloc_init(region,
                                fk->rk.dname, fk->rk.dname_len);
-               else    
+               } else  
                        dk->rk.dname = (uint8_t*)memdup(fk->rk.dname, 
                                fk->rk.dname_len);
                if(!dk->rk.dname)