From: Jo-Philipp Wich Date: Mon, 19 Nov 2018 10:58:17 +0000 (+0100) Subject: luci-base: cbi.js: fix sfh() signedness bug for strings with 3 trailing bytes X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=c55436e36fa9553373f14898c0dd04bad6ee4715;p=oweals%2Fluci.git 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 --- diff --git a/modules/luci-base/htdocs/luci-static/resources/cbi.js b/modules/luci-base/htdocs/luci-static/resources/cbi.js index 6cd799b92..0e9590681 100644 --- a/modules/luci-base/htdocs/luci-static/resources/cbi.js +++ b/modules/luci-base/htdocs/luci-static/resources/cbi.js @@ -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: