diff options
author | isaacs <i@izs.me> | 2011-07-06 13:12:21 -0700 |
---|---|---|
committer | isaacs <i@izs.me> | 2011-07-06 13:17:50 -0700 |
commit | 8475e1527ddc3fcfa3ed30846130e05e183935c6 (patch) | |
tree | f95f1c2a973a868c467df132002cc69c156739a4 | |
parent | 2a848fa7279002259a3e651223ce6f3230ca22d7 (diff) | |
download | nodejs-8475e1527ddc3fcfa3ed30846130e05e183935c6.tar.gz nodejs-8475e1527ddc3fcfa3ed30846130e05e183935c6.tar.bz2 nodejs-8475e1527ddc3fcfa3ed30846130e05e183935c6.zip |
punycode: Test for integer overflow
-rw-r--r-- | lib/punycode.js | 3 |
1 files changed, 2 insertions, 1 deletions
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.'); } } |