2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-09-03 16:15:27 +00:00

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

This commit is contained in:
Mark Andrews
2017-12-06 21:00:14 +11:00
parent a89f416017
commit 9d5a0abe81
9 changed files with 32 additions and 17 deletions

View File

@@ -1,3 +1,5 @@
4841. [bug] Address -fsanitize=undefined warnings. [RT #46786]
4840. [test] Add tests to cover fallback to using ZSK on inactive 4840. [test] Add tests to cover fallback to using ZSK on inactive
KSK. [RT #46787] KSK. [RT #46787]

View File

@@ -580,7 +580,7 @@ n=`expr $n + 1`
echo " I:wait for the zones to be loaded ($n)" echo " I:wait for the zones to be loaded ($n)"
ret=1 ret=1
try=0 try=0
while test $try -lt 45 while test $try -lt 100
do do
sleep 1 sleep 1
sed -n "$cur,"'$p' < ns6/named.run | grep "any newly configured zones are now loaded" > /dev/null && { sed -n "$cur,"'$p' < ns6/named.run | grep "any newly configured zones are now loaded" > /dev/null && {

View 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].code);
isc_buffer_putuint16(buf, ednsopts[i].length); isc_buffer_putuint16(buf, ednsopts[i].length);
isc_buffer_putmem(buf, ednsopts[i].value, if (ednsopts[i].length != 0) {
ednsopts[i].length); isc_buffer_putmem(buf, ednsopts[i].value,
ednsopts[i].length);
}
} }
/* Padding must be the final option */ /* Padding must be the final option */

View 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; len = (r->length < r2.length) ? r->length : r2.length;
if (len > DNS_NAME_MAXWIRE) if (len > DNS_NAME_MAXWIRE)
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->ndata = r2.base;
name->length = len; name->length = len;
} else { } else {
@@ -2050,8 +2051,11 @@ dns_name_towire2(const dns_name_t *name, dns_compress_t *cctx,
if (gf) { if (gf) {
if (ISC_UNLIKELY(target->length - target->used < gp.length)) if (ISC_UNLIKELY(target->length - target->used < gp.length))
return (ISC_R_NOSPACE); return (ISC_R_NOSPACE);
(void)memmove((unsigned char *)target->base + target->used, if (gp.length != 0) {
gp.ndata, (size_t)gp.length); unsigned char *base = target->base;
(void)memmove(base + target->used, gp.ndata,
(size_t)gp.length);
}
isc_buffer_add(target, gp.length); isc_buffer_add(target, gp.length);
if (ISC_UNLIKELY(target->length - target->used < 2)) if (ISC_UNLIKELY(target->length - target->used < 2))
return (ISC_R_NOSPACE); return (ISC_R_NOSPACE);
@@ -2066,8 +2070,11 @@ dns_name_towire2(const dns_name_t *name, dns_compress_t *cctx,
} else { } else {
if (ISC_UNLIKELY(target->length - target->used < name->length)) if (ISC_UNLIKELY(target->length - target->used < name->length))
return (ISC_R_NOSPACE); return (ISC_R_NOSPACE);
(void)memmove((unsigned char *)target->base + target->used, if (name->length != 0) {
name->ndata, (size_t)name->length); unsigned char *base = target->base;
(void)memmove(base + target->used, name->ndata,
(size_t)name->length);
}
isc_buffer_add(target, name->length); isc_buffer_add(target, name->length);
dns_compress_add(cctx, name, name, offset); dns_compress_add(cctx, name, name, offset);
if (comp_offsetp != NULL) 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; ndata = (unsigned char *)target->base + target->used;
dest->ndata = target->base; dest->ndata = target->base;
memmove(ndata, source->ndata, source->length); if (source->length != 0)
memmove(ndata, source->ndata, source->length);
dest->ndata = ndata; dest->ndata = ndata;
dest->labels = source->labels; dest->labels = source->labels;

View File

@@ -98,6 +98,8 @@ fromwire_opt(ARGS_FROMWIRE) {
UNUSED(options); UNUSED(options);
isc_buffer_activeregion(source, &sregion); isc_buffer_activeregion(source, &sregion);
if (sregion.length == 0)
return (ISC_R_SUCCESS);
total = 0; total = 0;
while (sregion.length != 0) { while (sregion.length != 0) {
if (sregion.length < 4) if (sregion.length < 4)

View File

@@ -1866,8 +1866,8 @@ update_quantum(isc_task_t *task, isc_event_t *event) {
break; break;
} }
result = dns_db_allrdatasets(rpz->updb, node, rpz->updbversion, 0, result = dns_db_allrdatasets(rpz->updb, node, rpz->updbversion,
&rdsiter); 0, &rdsiter);
if (result != ISC_R_SUCCESS) { if (result != ISC_R_SUCCESS) {
isc_log_write(dns_lctx, DNS_LOGCATEGORY_GENERAL, isc_log_write(dns_lctx, DNS_LOGCATEGORY_GENERAL,
DNS_LOGMODULE_MASTER, ISC_LOG_ERROR, DNS_LOGMODULE_MASTER, ISC_LOG_ERROR,

View File

@@ -82,8 +82,8 @@ isc_net_aton(const char *cp, struct in_addr *addr) {
int base; int base;
ptrdiff_t n; ptrdiff_t n;
unsigned char c; unsigned char c;
isc_uint8_t parts[4]; isc_uint32_t parts[4];
isc_uint8_t *pp = parts; isc_uint32_t *pp = parts;
int digit; int digit;
c = *cp; c = *cp;
@@ -135,7 +135,7 @@ isc_net_aton(const char *cp, struct in_addr *addr) {
*/ */
if (pp >= parts + 3 || val > 0xffU) if (pp >= parts + 3 || val > 0xffU)
return (0); return (0);
*pp++ = (isc_uint8_t)val; *pp++ = val;
c = *++cp; c = *++cp;
} else } else
break; break;

View File

@@ -140,7 +140,8 @@ isc_random_get(isc_uint32_t *val) {
*/ */
#if RAND_MAX >= 0xfffff #if RAND_MAX >= 0xfffff
/* We have at least 20 bits. Use lower 16 excluding lower most 4 */ /* 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 #elif RAND_MAX >= 0x7fff
/* We have at least 15 bits. Use lower 10/11 excluding lower most 4 */ /* We have at least 15 bits. Use lower 10/11 excluding lower most 4 */
*val = ((rand() >> 4) & 0x000007ff) | ((rand() << 7) & 0x003ff800) | *val = ((rand() >> 4) & 0x000007ff) | ((rand() << 7) & 0x003ff800) |

View File

@@ -194,14 +194,14 @@ tables_init(void) {
static isc_uint32_t static isc_uint32_t
matrix_binaryrank(isc_uint32_t *bits, ssize_t rows, ssize_t cols) { matrix_binaryrank(isc_uint32_t *bits, ssize_t rows, ssize_t cols) {
ssize_t i, j, k; ssize_t i, j, k;
int rt = 0; unsigned int rt = 0;
isc_uint32_t rank = 0; isc_uint32_t rank = 0;
isc_uint32_t tmp; isc_uint32_t tmp;
for (k = 0; k < rows; k++) { for (k = 0; k < rows; k++) {
i = k; i = k;
while (((bits[i] >> rt) & 1) == 0) { while (rt >= cols || ((bits[i] >> rt) & 1) == 0) {
i++; i++;
if (i < rows) if (i < rows)