From: Jo-Philipp Wich Date: Tue, 3 Sep 2019 17:25:39 +0000 (+0200) Subject: luci-base: cbi.js: fix unintended number sign overflow in format X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=41e2258d6dc1ebe8d3874ae6d6b13db49cff2c5c;p=oweals%2Fluci.git luci-base: cbi.js: fix unintended number sign overflow in format Fixes: #3003 Signed-off-by: Jo-Philipp Wich (backported from commit 6d9a23af60f796e14dd9652d4f401db1a5ac456f) --- diff --git a/modules/luci-base/htdocs/luci-static/resources/cbi.js b/modules/luci-base/htdocs/luci-static/resources/cbi.js index 47501bd47..da3f84e05 100644 --- a/modules/luci-base/htdocs/luci-static/resources/cbi.js +++ b/modules/luci-base/htdocs/luci-static/resources/cbi.js @@ -1403,7 +1403,7 @@ String.prototype.format = function() switch(pType) { case 'b': - subst = (+param || 0).toString(2); + subst = Math.floor(+param || 0).toString(2); break; case 'c': @@ -1411,11 +1411,12 @@ String.prototype.format = function() break; case 'd': - subst = ~~(+param || 0); + subst = Math.floor(+param || 0).toFixed(0); break; case 'u': - subst = ~~Math.abs(+param || 0); + var n = +param || 0; + subst = Math.floor((n < 0) ? 0x100000000 + n : n).toFixed(0); break; case 'f': @@ -1425,7 +1426,7 @@ String.prototype.format = function() break; case 'o': - subst = (+param || 0).toString(8); + subst = Math.floor(+param || 0).toString(8); break; case 's': @@ -1433,11 +1434,11 @@ String.prototype.format = function() break; case 'x': - subst = ('' + (+param || 0).toString(16)).toLowerCase(); + subst = Math.floor(+param || 0).toString(16).toLowerCase(); break; case 'X': - subst = ('' + (+param || 0).toString(16)).toUpperCase(); + subst = Math.floor(+param || 0).toString(16).toUpperCase(); break; case 'h':