summaryrefslogtreecommitdiffstats
path: root/libutils/JenkinsHash.cpp
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 @@
* should still be quite good.
**/
+#include <stdlib.h>
#include <utils/JenkinsHash.h>
namespace android {
+#ifdef __clang__
+__attribute__((no_sanitize("integer")))
+#endif
hash_t JenkinsHashWhiten(uint32_t hash) {
hash += (hash << 3);
hash ^= (hash >> 11);
@@ -31,6 +35,9 @@ hash_t JenkinsHashWhiten(uint32_t hash) {
}
uint32_t JenkinsHashMixBytes(uint32_t hash, const uint8_t* bytes, size_t size) {
+ if (size > UINT32_MAX) {
+ abort();
+ }
hash = JenkinsHashMix(hash, (uint32_t)size);
size_t i;
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) {
}
uint32_t JenkinsHashMixShorts(uint32_t hash, const uint16_t* shorts, size_t size) {
+ if (size > UINT32_MAX) {
+ abort();
+ }
hash = JenkinsHashMix(hash, (uint32_t)size);
size_t i;
for (i = 0; i < (size & -2); i += 2) {