[master] Type the shifted values to isc_uint32_t so the top bit is unsigned (found by UBSAN) [RT #46740]

This commit is contained in:
Ondřej Surý 2017-11-30 18:23:35 +01:00
parent 2c20fc0d13
commit a4a148cf9a
5 changed files with 12 additions and 12 deletions

View file

@ -181,7 +181,7 @@ static void
do_store(isc_task_t *task, isc_event_t *ev) {
counter_t *state = (counter_t *)ev->ev_arg;
int i;
isc_uint8_t r;
isc_uint32_t r;
isc_uint32_t val;
r = random() % 256;
@ -205,7 +205,7 @@ test_atomic_store() {
isc_task_t *tasks[TASKS];
isc_event_t *event;
int i;
isc_uint8_t r;
isc_uint32_t r;
isc_uint32_t val;
t_assert("test_atomic_store", 1, T_REQUIRED, "%s",

View file

@ -421,10 +421,10 @@ static isc_uint32_t
dns_hash(dns_qid_t *qid, const isc_sockaddr_t *dest, dns_messageid_t id,
in_port_t port)
{
unsigned int ret;
isc_uint32_t ret;
ret = isc_sockaddr_hash(dest, ISC_TRUE);
ret ^= (id << 16) | port;
ret ^= ((isc_uint32_t)id << 16) | port;
ret %= qid->qid_nbuckets;
INSIST(ret < qid->qid_nbuckets);

View file

@ -307,7 +307,7 @@ typedef isc_uint32_t rbtdb_rdatatype_t;
#define RBTDB_RDATATYPE_BASE(type) ((dns_rdatatype_t)((type) & 0xFFFF))
#define RBTDB_RDATATYPE_EXT(type) ((dns_rdatatype_t)((type) >> 16))
#define RBTDB_RDATATYPE_VALUE(b, e) ((rbtdb_rdatatype_t)((e) << 16) | (b))
#define RBTDB_RDATATYPE_VALUE(base, ext) ((rbtdb_rdatatype_t)(((isc_uint32_t)ext) << 16) | ((isc_uint32_t)base) & 0xffff)
#define RBTDB_RDATATYPE_SIGNSEC \
RBTDB_RDATATYPE_VALUE(dns_rdatatype_rrsig, dns_rdatatype_nsec)

View file

@ -1796,10 +1796,10 @@ uint32_fromregion(isc_region_t *region) {
isc_uint32_t value;
REQUIRE(region->length >= 4);
value = region->base[0] << 24;
value |= region->base[1] << 16;
value |= region->base[2] << 8;
value |= region->base[3];
value = (isc_uint32_t)region->base[0] << 24;
value |= (isc_uint32_t)region->base[1] << 16;
value |= (isc_uint32_t)region->base[2] << 8;
value |= (isc_uint32_t)region->base[3];
return(value);
}

View file

@ -32,14 +32,14 @@ struct isc_portset {
static inline isc_boolean_t
portset_isset(isc_portset_t *portset, in_port_t port) {
return (ISC_TF((portset->buf[port >> 5] & (1 << (port & 31))) != 0));
return (ISC_TF((portset->buf[port >> 5] & ((isc_uint32_t)1 << (port & 31))) != 0));
}
static inline void
portset_add(isc_portset_t *portset, in_port_t port) {
if (!portset_isset(portset, port)) {
portset->nports++;
portset->buf[port >> 5] |= (1 << (port & 31));
portset->buf[port >> 5] |= ((isc_uint32_t)1 << (port & 31));
}
}
@ -47,7 +47,7 @@ static inline void
portset_remove(isc_portset_t *portset, in_port_t port) {
if (portset_isset(portset, port)) {
portset->nports--;
portset->buf[port >> 5] &= ~(1 << (port & 31));
portset->buf[port >> 5] &= ~((isc_uint32_t)1 << (port & 31));
}
}