Commit a6f99bb3 authored by Michał Kępień's avatar Michał Kępień
Browse files

Merge branch '258-address-ubsan-warnings' into 'master'

Address issues found by ubsan

Closes #258

See merge request !278
parents 34de85da 6ddbca6f
Pipeline #1681 passed with stages
in 7 minutes and 51 seconds
......@@ -796,7 +796,8 @@ dns_rdataslab_merge(unsigned char *oslab, unsigned char *nslab,
else if (nadded == ncount)
fromold = ISC_TRUE;
else
fromold = ISC_TF(compare_rdata(&ordata, &nrdata) < 0);
fromold = ISC_TF(dns_rdata_compare(&ordata,
&nrdata) < 0);
if (fromold) {
#if DNS_RDATASET_FIXED
offsettable[oorder] = tcurrent - offsetbase;
......
......@@ -59,7 +59,10 @@ isc_buffer_reinit(isc_buffer_t *b, void *base, unsigned int length) {
REQUIRE(base != NULL);
REQUIRE(!b->autore);
(void)memmove(base, b->base, b->length);
if (b->length > 0U) {
(void)memmove(base, b->base, b->length);
}
b->base = base;
b->length = length;
}
......@@ -253,7 +256,9 @@ isc_buffer_compact(isc_buffer_t *b) {
src = isc_buffer_current(b);
length = isc_buffer_remaininglength(b);
(void)memmove(b->base, src, (size_t)length);
if (length > 0U) {
(void)memmove(b->base, src, (size_t)length);
}
if (b->active > b->current)
b->active -= b->current;
......@@ -526,8 +531,10 @@ isc_buffer_copyregion(isc_buffer_t *b, const isc_region_t *r) {
}
if (r->length > available)
return (ISC_R_NOSPACE);
memmove(base, r->base, r->length);
b->used += r->length;
if (r->length > 0U) {
memmove(base, r->base, r->length);
b->used += r->length;
}
return (ISC_R_SUCCESS);
}
......
......@@ -920,8 +920,10 @@ ISC_LANG_ENDDECLS
== ISC_R_SUCCESS); \
} \
ISC_REQUIRE(isc_buffer_availablelength(_b) >= (unsigned int) _length); \
memmove(isc_buffer_used(_b), (_base), (_length)); \
(_b)->used += (_length); \
if (_length > 0U) { \
memmove(isc_buffer_used(_b), (_base), (_length)); \
(_b)->used += (_length); \
} \
} while (0)
#define ISC__BUFFER_PUTSTR(_b, _source) \
......
......@@ -166,7 +166,7 @@ isc_netaddr_totext(const isc_netaddr_t *netaddr, isc_buffer_t *target) {
return (ISC_R_NOSPACE);
isc_buffer_putmem(target, (unsigned char *)abuf, alen);
isc_buffer_putmem(target, (unsigned char *)zbuf, zlen);
isc_buffer_putmem(target, (unsigned char *)zbuf, (unsigned int)zlen);
return (ISC_R_SUCCESS);
}
......
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