memset() was sometimes bypassed for some reason in dns_cache_clone_entry()
authorMiklos Tirpak <miklos@iptel.org>
Mon, 13 Aug 2007 14:33:57 +0000 (14:33 +0000)
committerMiklos Tirpak <miklos@iptel.org>
Mon, 13 Aug 2007 14:33:57 +0000 (14:33 +0000)
dns_cache.c

index df8e39e..808f05a 100644 (file)
@@ -3458,6 +3458,7 @@ static struct dns_hash_entry *dns_cache_clone_entry(struct dns_hash_entry *e, in
                LOG(L_ERR, "ERROR: dns_cache_clone_entry: out of memory\n");
                return NULL;
        }
+       memset(new, 0, rounded_size+rr_size+rdata_size);
        /* clone the entry */
        memcpy(new, e, size);
        /* fix the values and pointers */
@@ -3500,8 +3501,6 @@ static struct dns_hash_entry *dns_cache_clone_entry(struct dns_hash_entry *e, in
 
 
        if (rdata_size) {
-               memset(new+size, 0, rounded_size-size+rr_size+rdata_size);
-
                /* set the pointer to the new rr structure */
                new_rr = (void*)((char*)new + rounded_size);
                new_rr->rdata = (void*)((char*)new_rr+rr_size);