]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
- Fix #1154: segfault when reading config with duplicate zones.
authorWouter Wijngaards <wouter@nlnetlabs.nl>
Fri, 4 Nov 2016 08:16:55 +0000 (08:16 +0000)
committerWouter Wijngaards <wouter@nlnetlabs.nl>
Fri, 4 Nov 2016 08:16:55 +0000 (08:16 +0000)
git-svn-id: file:///svn/unbound/trunk@3922 be551aaa-1e26-0410-a405-d3ace91eadb9

doc/Changelog
services/localzone.c

index bdf5be62775b54073d57594cfb9da6c3c29c391b..89eeea9ef0ebc3389fe65c11f526b1e33129b3cc 100644 (file)
@@ -2,6 +2,7 @@
        - configure detects ssl security level API function in the autoconf
          manner.  Every function on its own, so that other libraries (eg.
          LibreSSL) can develop their API without hindrance.
+       - Fix #1154: segfault when reading config with duplicate zones.
 
 3 November 2016: Ralph
        - Set OpenSSL security level to 0 when using aNULL ciphers.
index 7d73f37662426e226f1334cc8f022cfca3a487e2..8b12b663cb288a79f0e87b2d9df637f5623d5b87 100644 (file)
@@ -186,13 +186,17 @@ lz_enter_zone_dname(struct local_zones* zones, uint8_t* nm, size_t len,
        lock_rw_wrlock(&zones->lock);
        lock_rw_wrlock(&z->lock);
        if(!rbtree_insert(&zones->ztree, &z->node)) {
+               struct local_zone* oldz;
                log_warn("duplicate local-zone");
                lock_rw_unlock(&z->lock);
-               local_zone_delete(z);
+               /* save zone name locally before deallocation,
+                * otherwise, nm is gone if we zone_delete now. */
+               oldz = z;
                /* find the correct zone, so not an error for duplicate */
                z = local_zones_find(zones, nm, len, labs, c);
                lock_rw_wrlock(&z->lock);
                lock_rw_unlock(&zones->lock);
+               local_zone_delete(oldz);
                return z;
        }
        lock_rw_unlock(&zones->lock);