Browse Source

punycode: Test for integer overflow

v0.7.4-release
isaacs 14 years ago
parent
commit
8475e1527d
  1. 3
      lib/punycode.js

3
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.');
}
}

Loading…
Cancel
Save