summaryrefslogtreecommitdiffhomepage
path: root/modules/luci-base/src/template_lmo.c
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2018-11-19 13:28:52 +0100
committerJo-Philipp Wich <jo@mein.io>2018-11-19 13:31:43 +0100
commit51de74d5201b0a1e314ed24cb1003dc3cf701633 (patch)
tree41cba24ac1dd8c73e49eea79778fdcd5be146b39 /modules/luci-base/src/template_lmo.c
parentc55436e36fa9553373f14898c0dd04bad6ee4715 (diff)
luci-base: further hash calculation signedness bugfixes
- cbi.js: make sure to treat single bytes as signed char when handling end cases - template_lmo.c: make sure to treat single bytes as signed char when handling end cases, avoids hash miscalculations on ARM Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'modules/luci-base/src/template_lmo.c')
-rw-r--r--modules/luci-base/src/template_lmo.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/modules/luci-base/src/template_lmo.c b/modules/luci-base/src/template_lmo.c
index cd4c609a7..f7a118c9b 100644
--- a/modules/luci-base/src/template_lmo.c
+++ b/modules/luci-base/src/template_lmo.c
@@ -46,14 +46,14 @@ uint32_t sfh_hash(const char *data, int len)
switch (rem) {
case 3: hash += sfh_get16(data);
hash ^= hash << 16;
- hash ^= data[sizeof(uint16_t)] << 18;
+ hash ^= (signed char)data[sizeof(uint16_t)] << 18;
hash += hash >> 11;
break;
case 2: hash += sfh_get16(data);
hash ^= hash << 11;
hash += hash >> 17;
break;
- case 1: hash += *data;
+ case 1: hash += (signed char)*data;
hash ^= hash << 10;
hash += hash >> 1;
}