Commit 9d5a0abe authored by Mark Andrews's avatar Mark Andrews

4841. [bug] Address -fsanitize=undefined warnings. [RT #46786]

parent a89f4160
4841. [bug] Address -fsanitize=undefined warnings. [RT #46786]
4840. [test] Add tests to cover fallback to using ZSK on inactive
KSK. [RT #46787]
......
......@@ -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 && {
......
......@@ -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 */
......
......@@ -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;
......
......@@ -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)
......
......@@ -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,
......
......@@ -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;
......
......@@ -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) |
......
......@@ -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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment