diff options
author | Craig Tiller <ctiller@google.com> | 2016-05-03 23:10:07 -0700 |
---|---|---|
committer | Craig Tiller <ctiller@google.com> | 2016-05-03 23:10:07 -0700 |
commit | 68897999237ab5d67278365b3bd444960fa3c4c0 (patch) | |
tree | c10656bd6f00c7c265adcf939d3680c4dec0e3ac /src/core/lib/support | |
parent | 525654a164a8862e14de913753100345932af2fc (diff) |
Fix some ubsan issues: I fear no bugs were harmed in the making of this episode
Diffstat (limited to 'src/core/lib/support')
-rw-r--r-- | src/core/lib/support/murmur_hash.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/src/core/lib/support/murmur_hash.c b/src/core/lib/support/murmur_hash.c index 5711fff0c0..7137c1f313 100644 --- a/src/core/lib/support/murmur_hash.c +++ b/src/core/lib/support/murmur_hash.c @@ -33,6 +33,8 @@ #include "src/core/lib/support/murmur_hash.h" +#include <string.h> + #define ROTL32(x, r) ((x) << (r)) | ((x) >> (32 - (r))) #define FMIX32(h) \ @@ -42,10 +44,6 @@ (h) *= 0xc2b2ae35; \ (h) ^= (h) >> 16; -/* Block read - if your platform needs to do endian-swapping or can only - handle aligned reads, do the conversion here */ -#define GETBLOCK32(p, i) (p)[(i)] - uint32_t gpr_murmur_hash3(const void *key, size_t len, uint32_t seed) { const uint8_t *data = (const uint8_t *)key; const size_t nblocks = len / 4; @@ -62,7 +60,7 @@ uint32_t gpr_murmur_hash3(const void *key, size_t len, uint32_t seed) { /* body */ for (i = -(int)nblocks; i; i++) { - k1 = GETBLOCK32(blocks, i); + memcpy(&k1, blocks + i, sizeof(uint32_t)); k1 *= c1; k1 = ROTL32(k1, 15); |