#if ACISM_SIZE < 8
psp->sym_bits = bitwid(psp->nsyms);
- psp->sym_mask = ~(-1 << psp->sym_bits);
+ psp->sym_mask = ~((~0u) << psp->sym_bits);
#endif
}
static inline uint32_t
ucl_hash_func (const ucl_object_t *o)
{
- return rspamd_cryptobox_fast_hash (o->key, o->keylen, 0xb9a1ef83c4561c95ULL);
+ return (uint32_t)rspamd_cryptobox_fast_hash (o->key, o->keylen, 0xb9a1ef83c4561c95ULL);
}
static inline int
break;
}
- return rspamd_cryptobox_fast_hash_final (&hst);
+ return (uint32_t)rspamd_cryptobox_fast_hash_final (&hst);
}
#define INNER_LOOP_64 do { \
while (inlen >= 13) { \
uint64_t str, res, dec; \
- str = *(uint64_t *)c; \
+ memcpy(&str, c, sizeof(str)); \
str = GUINT64_TO_BE(str); \
if ((dec = base64_table_dec[str >> 56]) > 63) { \
break; \
#define INNER_LOOP_32 do { \
while (inlen >= 8) { \
uint32_t str, res, dec; \
- str = *(uint32_t *)c; \
+ memcpy(&str, c, sizeof(str)); \
str = GUINT32_TO_BE(str); \
if ((dec = base64_table_dec[str >> 24]) > 63) { \
break; \
* 192.168 -> 192.0.0.168
*/
shift = 8 * (4 - i);
- n |= t << shift;
+
+ if (shift < 32) {
+ n |= t << shift;
+ }
if (check_num && dots <= 4) {
memcpy (&in4, &n, sizeof (in4));
len = strlen (p);
- return rspamd_icase_hash (p, len, rspamd_hash_seed ());
+ return (guint)rspamd_icase_hash (p, len, rspamd_hash_seed ());
}
guint
{
const rspamd_ftok_t *f = key;
- return rspamd_icase_hash (f->begin, f->len, rspamd_hash_seed ());
+ return (guint)rspamd_icase_hash (f->begin, f->len, rspamd_hash_seed ());
}
gboolean
cols = 0;
while (inlen > 6) {
- n = *(guint64 *)in;
+ memcpy (&n, in, sizeof (n));
n = GUINT64_TO_BE (n);
if (str_len <= 0 || cols <= str_len - 8) {
/* Utils for uthash tuning */
#ifndef HASH_CASELESS
#define HASH_FUNCTION(key,keylen,num_bkts,hashv,bkt) do {\
- hashv = rspamd_cryptobox_fast_hash(key, keylen, rspamd_hash_seed ()); \
+ hashv = (__typeof (hashv))rspamd_cryptobox_fast_hash(key, keylen, rspamd_hash_seed ()); \
bkt = (hashv) & (num_bkts-1); \
} while (0)
rspamd_cryptobox_fast_hash_update (&_hst, &_u, sizeof (_u)); \
break; \
} \
- hashv = rspamd_cryptobox_fast_hash_final (&_hst); \
+ hashv = (__typeof (hashv))rspamd_cryptobox_fast_hash_final (&_hst); \
bkt = (hashv) & (num_bkts-1); \
} while (0)
#define HASH_KEYCMP(a,b,len) rspamd_lc_cmp(a,b,len)