From 8475e1527ddc3fcfa3ed30846130e05e183935c6 Mon Sep 17 00:00:00 2001 From: isaacs Date: Wed, 6 Jul 2011 13:12:21 -0700 Subject: punycode: Test for integer overflow --- lib/punycode.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/punycode.js b/lib/punycode.js index a7c07a663..64d8c61ad 100644 --- a/lib/punycode.js +++ b/lib/punycode.js @@ -28,6 +28,7 @@ var SKEW = 38; var DAMP = 700; // initial bias scaler var INITIAL_N = 128; var INITIAL_BIAS = 72; +var MAX_INTEGER = Math.pow(2, 53); function adapt_bias(delta, n_points, is_first) { // scale back, then increase delta @@ -151,7 +152,7 @@ function encode(input) { for (var i = 0; i < len; ++i) { var c = input[i]; if (c < n) { - if (++delta == 0) { + if (++delta == MAX_INTEGER) { throw new Error('Delta overflow.'); } } -- cgit v1.2.3