From 6d9a23af60f796e14dd9652d4f401db1a5ac456f Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Tue, 3 Sep 2019 19:25:39 +0200 Subject: luci-base: cbi.js: fix unintended number sign overflow in format Fixes: #3003 Signed-off-by: Jo-Philipp Wich --- modules/luci-base/htdocs/luci-static/resources/cbi.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'modules') diff --git a/modules/luci-base/htdocs/luci-static/resources/cbi.js b/modules/luci-base/htdocs/luci-static/resources/cbi.js index d4d61eb38..a3528fcac 100644 --- a/modules/luci-base/htdocs/luci-static/resources/cbi.js +++ b/modules/luci-base/htdocs/luci-static/resources/cbi.js @@ -566,7 +566,7 @@ String.prototype.format = function() switch(pType) { case 'b': - subst = (~~param || 0).toString(2); + subst = Math.floor(+param || 0).toString(2); break; case 'c': @@ -574,11 +574,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': @@ -588,7 +589,7 @@ String.prototype.format = function() break; case 'o': - subst = (~~param || 0).toString(8); + subst = Math.floor(+param || 0).toString(8); break; case 's': @@ -596,11 +597,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': -- cgit v1.2.3