luci-base: cbi.js: fix sfh() signedness bug for strings with 3 trailing bytes

Replace a sign-propagating right shift by a zero-filling right shift to avoid
calculating a wrong hash code in the three-trailing-bytes case.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
This commit is contained in:
Jo-Philipp Wich 2018-11-19 11:58:17 +01:00
parent 2babc47ae2
commit c55436e36f

View file

@ -60,7 +60,7 @@ function sfh(s) {
hash += ((bytes[off + 1] << 8) + bytes[off]) >>> 0;
hash = (hash ^ (hash << 16)) >>> 0;
hash = (hash ^ (bytes[off + 2] << 18)) >>> 0;
hash += hash >> 11;
hash += hash >>> 11;
break;
case 2: