]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
4841. [bug] Address -fsanitize=undefined warnings. [RT #46786]
authorMark Andrews <marka@isc.org>
Wed, 6 Dec 2017 10:00:14 +0000 (21:00 +1100)
committerMark Andrews <marka@isc.org>
Wed, 6 Dec 2017 10:00:14 +0000 (21:00 +1100)
CHANGES
bin/tests/system/rndc/tests.sh
lib/dns/message.c
lib/dns/name.c
lib/dns/rdata/generic/opt_41.c
lib/dns/rpz.c
lib/isc/inet_aton.c
lib/isc/random.c
lib/isc/tests/random_test.c

diff --git a/CHANGES b/CHANGES
index 2ff6d371de799b81584f23115e9eec9d5b3d18ab..cde7a5368e051f77f483844f9758f7ede0deb132 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,5 @@
+4841.  [bug]           Address -fsanitize=undefined warnings. [RT #46786]
+
 4840.  [test]          Add tests to cover fallback to using ZSK on inactive
                        KSK. [RT #46787]
 
index 141fa7b3e5b1b8d6a563d72a1ae8330cbba61096..112adf11325f7495c166c9cd840383173ad87b91 100644 (file)
@@ -580,7 +580,7 @@ n=`expr $n + 1`
 echo " I:wait for the zones to be loaded ($n)"
 ret=1
 try=0
-while test $try -lt 45
+while test $try -lt 100
 do
     sleep 1
     sed -n "$cur,"'$p' < ns6/named.run | grep "any newly configured zones are now loaded" > /dev/null && {
index 081952385d4e3769285358cc9706ffe287c03a41..541fafd056983d57ef8ed9914fde57d811ee4379 100644 (file)
@@ -4401,8 +4401,10 @@ dns_message_buildopt(dns_message_t *message, dns_rdataset_t **rdatasetp,
                        }
                        isc_buffer_putuint16(buf, ednsopts[i].code);
                        isc_buffer_putuint16(buf, ednsopts[i].length);
-                       isc_buffer_putmem(buf, ednsopts[i].value,
-                                         ednsopts[i].length);
+                       if (ednsopts[i].length != 0) {
+                               isc_buffer_putmem(buf, ednsopts[i].value,
+                                                 ednsopts[i].length);
+                       }
                }
 
                /* Padding must be the final option */
index 9588c40f58a49512cd69ca5f3ff3557ebf99b734..d42543d57e1d67324e79b0d45a1d92b68a08b9e7 100644 (file)
@@ -1044,7 +1044,8 @@ dns_name_fromregion(dns_name_t *name, const isc_region_t *r) {
                len = (r->length < r2.length) ? r->length : r2.length;
                if (len > DNS_NAME_MAXWIRE)
                        len = DNS_NAME_MAXWIRE;
-               memmove(r2.base, r->base, len);
+               if (len != 0)
+                       memmove(r2.base, r->base, len);
                name->ndata = r2.base;
                name->length = len;
        } else {
@@ -2050,8 +2051,11 @@ dns_name_towire2(const dns_name_t *name, dns_compress_t *cctx,
        if (gf) {
                if (ISC_UNLIKELY(target->length - target->used < gp.length))
                        return (ISC_R_NOSPACE);
-               (void)memmove((unsigned char *)target->base + target->used,
-                             gp.ndata, (size_t)gp.length);
+               if (gp.length != 0) {
+                       unsigned char *base = target->base;
+                       (void)memmove(base + target->used, gp.ndata,
+                                     (size_t)gp.length);
+               }
                isc_buffer_add(target, gp.length);
                if (ISC_UNLIKELY(target->length - target->used < 2))
                        return (ISC_R_NOSPACE);
@@ -2066,8 +2070,11 @@ dns_name_towire2(const dns_name_t *name, dns_compress_t *cctx,
        } else {
                if (ISC_UNLIKELY(target->length - target->used < name->length))
                        return (ISC_R_NOSPACE);
-               (void)memmove((unsigned char *)target->base + target->used,
-                             name->ndata, (size_t)name->length);
+               if (name->length != 0) {
+                       unsigned char *base = target->base;
+                       (void)memmove(base + target->used, name->ndata,
+                                     (size_t)name->length);
+               }
                isc_buffer_add(target, name->length);
                dns_compress_add(cctx, name, name, offset);
                if (comp_offsetp != NULL)
@@ -2542,7 +2549,8 @@ dns_name_copy(const dns_name_t *source, dns_name_t *dest, isc_buffer_t *target)
        ndata = (unsigned char *)target->base + target->used;
        dest->ndata = target->base;
 
-       memmove(ndata, source->ndata, source->length);
+       if (source->length != 0)
+               memmove(ndata, source->ndata, source->length);
 
        dest->ndata = ndata;
        dest->labels = source->labels;
index 71e7be2d3d74ba050b9eeead2ab2fffee045fa4b..a124c3dd736dcad993e73e4642c765233ffa791b 100644 (file)
@@ -98,6 +98,8 @@ fromwire_opt(ARGS_FROMWIRE) {
        UNUSED(options);
 
        isc_buffer_activeregion(source, &sregion);
+       if (sregion.length == 0)
+               return (ISC_R_SUCCESS);
        total = 0;
        while (sregion.length != 0) {
                if (sregion.length < 4)
index 2f98e6702123af3f037a5295bc342fc49710ec76..ea3e014fd4f715a796f4a51c9bc1e57c05edb6ea 100644 (file)
@@ -1866,8 +1866,8 @@ update_quantum(isc_task_t *task, isc_event_t *event) {
                        break;
                }
 
-               result = dns_db_allrdatasets(rpz->updb, node, rpz->updbversion, 0,
-                                            &rdsiter);
+               result = dns_db_allrdatasets(rpz->updb, node, rpz->updbversion,
+                                            0, &rdsiter);
                if (result != ISC_R_SUCCESS) {
                        isc_log_write(dns_lctx, DNS_LOGCATEGORY_GENERAL,
                                      DNS_LOGMODULE_MASTER, ISC_LOG_ERROR,
index 83e6334362c312d3f18b91c26a686600eed5a027..403936a52c2d2b6fec8e46e4f167a4eda2f9b8cf 100644 (file)
@@ -82,8 +82,8 @@ isc_net_aton(const char *cp, struct in_addr *addr) {
        int base;
        ptrdiff_t n;
        unsigned char c;
-       isc_uint8_t parts[4];
-       isc_uint8_t *pp = parts;
+       isc_uint32_t parts[4];
+       isc_uint32_t *pp = parts;
        int digit;
 
        c = *cp;
@@ -135,7 +135,7 @@ isc_net_aton(const char *cp, struct in_addr *addr) {
                         */
                        if (pp >= parts + 3 || val > 0xffU)
                                return (0);
-                       *pp++ = (isc_uint8_t)val;
+                       *pp++ = val;
                        c = *++cp;
                } else
                        break;
index 91441b22ffb74687f3e3f36a911acac210759fe1..f0ff9cfbfb193f4abdfd893231ae2ce56e122557 100644 (file)
@@ -140,7 +140,8 @@ isc_random_get(isc_uint32_t *val) {
         */
 #if RAND_MAX >= 0xfffff
        /* We have at least 20 bits.  Use lower 16 excluding lower most 4 */
-       *val = ((rand() >> 4) & 0xffff) | ((rand() << 12) & 0xffff0000);
+       *val = ((((unsigned int)rand()) & 0xffff0) >> 4) |
+              ((((unsigned int)rand()) & 0xffff0) << 12);
 #elif RAND_MAX >= 0x7fff
        /* We have at least 15 bits.  Use lower 10/11 excluding lower most 4 */
        *val = ((rand() >> 4) & 0x000007ff) | ((rand() << 7) & 0x003ff800) |
index fc0b74ad2ee37c8ea8ec9b0bc4709ea5fe78a7f8..03e38e6f33a6474e38cd41533e612ba2458e5ae3 100644 (file)
@@ -194,14 +194,14 @@ tables_init(void) {
 static isc_uint32_t
 matrix_binaryrank(isc_uint32_t *bits, ssize_t rows, ssize_t cols) {
        ssize_t i, j, k;
-       int rt = 0;
+       unsigned int rt = 0;
        isc_uint32_t rank = 0;
        isc_uint32_t tmp;
 
        for (k = 0; k < rows; k++) {
                i = k;
 
-               while (((bits[i] >> rt) & 1) == 0) {
+               while (rt >= cols || ((bits[i] >> rt) & 1) == 0) {
                        i++;
 
                        if (i < rows)