]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
- Fix more undefined sanitizer issues, in respip copy_rrset null
authorW.C.A. Wijngaards <wouter@nlnetlabs.nl>
Thu, 27 Feb 2020 14:43:27 +0000 (15:43 +0100)
committerW.C.A. Wijngaards <wouter@nlnetlabs.nl>
Thu, 27 Feb 2020 14:43:27 +0000 (15:43 +0100)
  dname, and in the client_info_compare routine for null memcmp.

doc/Changelog
respip/respip.c
services/mesh.c

index 407c0d34df8c0ca4f0ae80d9ace6f2024449ab1f..68fd123beff1ab897cca97c826966e265cf85ef3 100644 (file)
@@ -3,6 +3,8 @@
          from snprintf.
        - Fix #170: Fix gcc undefined sanitizer signed integer overflow
          warning in signature expiry RFC1982 serial number arithmetic.
+       - Fix more undefined sanitizer issues, in respip copy_rrset null
+         dname, and in the client_info_compare routine for null memcmp.
 
 26 February 2020: Wouter
        - iana portlist updated.
index f504f55791ac07c2b05a4df16f118bdf2f6c2beb..c496653c41dd3bb5158ddef3b75ac94bee3b0cd9 100644 (file)
@@ -502,10 +502,16 @@ copy_rrset(const struct ub_packed_rrset_key* key, struct regional* region)
        ck->entry.hash = key->entry.hash;
        ck->entry.key = ck;
        ck->rk = key->rk;
-       ck->rk.dname = regional_alloc_init(region, key->rk.dname,
-               key->rk.dname_len);
-       if(!ck->rk.dname)
-               return NULL;
+       if(key->rk.dname) {
+               ck->rk.dname = regional_alloc_init(region, key->rk.dname,
+                       key->rk.dname_len);
+               if(!ck->rk.dname)
+                       return NULL;
+               ck->rk.dname_len = key->rk.dname_len;
+       } else {
+               ck->rk.dname = NULL;
+               ck->rk.dname_len = 0;
+       }
 
        if((unsigned)data->count >= 0xffff00U)
                return NULL; /* guard against integer overflow in dsize */
index 9114ef4c4e2d7c37908a75d55d052eac48db825c..09c51a2be5cf7828420ef225388c9cdcac045763 100644 (file)
@@ -159,16 +159,28 @@ client_info_compare(const struct respip_client_info* ci_a,
                return 1;
        if(ci_a->taglen != ci_b->taglen)
                return (ci_a->taglen < ci_b->taglen) ? -1 : 1;
-       cmp = memcmp(ci_a->taglist, ci_b->taglist, ci_a->taglen);
-       if(cmp != 0)
-               return cmp;
+       if(ci_a->taglist && !ci_b->taglist)
+               return -1;
+       if(!ci_a->taglist && ci_b->taglist)
+               return 1;
+       if(ci_a->taglist && ci_b->taglist) {
+               cmp = memcmp(ci_a->taglist, ci_b->taglist, ci_a->taglen);
+               if(cmp != 0)
+                       return cmp;
+       }
        if(ci_a->tag_actions_size != ci_b->tag_actions_size)
                return (ci_a->tag_actions_size < ci_b->tag_actions_size) ?
                        -1 : 1;
-       cmp = memcmp(ci_a->tag_actions, ci_b->tag_actions,
-               ci_a->tag_actions_size);
-       if(cmp != 0)
-               return cmp;
+       if(ci_a->tag_actions && !ci_b->tag_actions)
+               return -1;
+       if(!ci_a->tag_actions && ci_b->tag_actions)
+               return 1;
+       if(ci_a->tag_actions && ci_b->tag_actions) {
+               cmp = memcmp(ci_a->tag_actions, ci_b->tag_actions,
+                       ci_a->tag_actions_size);
+               if(cmp != 0)
+                       return cmp;
+       }
        if(ci_a->tag_datas != ci_b->tag_datas)
                return ci_a->tag_datas < ci_b->tag_datas ? -1 : 1;
        if(ci_a->view != ci_b->view)