summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'libutils/JenkinsHash.cpp')
-rw-r--r--libutils/JenkinsHash.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/libutils/JenkinsHash.cpp b/libutils/JenkinsHash.cpp
index 52c9bb7df..ff5d252a4 100644
--- a/libutils/JenkinsHash.cpp
+++ b/libutils/JenkinsHash.cpp
@@ -19,10 +19,14 @@
19 * should still be quite good. 19 * should still be quite good.
20 **/ 20 **/
21 21
22#include <stdlib.h>
22#include <utils/JenkinsHash.h> 23#include <utils/JenkinsHash.h>
23 24
24namespace android { 25namespace android {
25 26
27#ifdef __clang__
28__attribute__((no_sanitize("integer")))
29#endif
26hash_t JenkinsHashWhiten(uint32_t hash) { 30hash_t JenkinsHashWhiten(uint32_t hash) {
27 hash += (hash << 3); 31 hash += (hash << 3);
28 hash ^= (hash >> 11); 32 hash ^= (hash >> 11);
@@ -31,6 +35,9 @@ hash_t JenkinsHashWhiten(uint32_t hash) {
31} 35}
32 36
33uint32_t JenkinsHashMixBytes(uint32_t hash, const uint8_t* bytes, size_t size) { 37uint32_t JenkinsHashMixBytes(uint32_t hash, const uint8_t* bytes, size_t size) {
38 if (size > UINT32_MAX) {
39 abort();
40 }
34 hash = JenkinsHashMix(hash, (uint32_t)size); 41 hash = JenkinsHashMix(hash, (uint32_t)size);
35 size_t i; 42 size_t i;
36 for (i = 0; i < (size & -4); i += 4) { 43 for (i = 0; i < (size & -4); i += 4) {
@@ -47,6 +54,9 @@ uint32_t JenkinsHashMixBytes(uint32_t hash, const uint8_t* bytes, size_t size) {
47} 54}
48 55
49uint32_t JenkinsHashMixShorts(uint32_t hash, const uint16_t* shorts, size_t size) { 56uint32_t JenkinsHashMixShorts(uint32_t hash, const uint16_t* shorts, size_t size) {
57 if (size > UINT32_MAX) {
58 abort();
59 }
50 hash = JenkinsHashMix(hash, (uint32_t)size); 60 hash = JenkinsHashMix(hash, (uint32_t)size);
51 size_t i; 61 size_t i;
52 for (i = 0; i < (size & -2); i += 2) { 62 for (i = 0; i < (size & -2); i += 2) {