diff --git a/lib/internal/http2/core.js b/lib/internal/http2/core.js index 4a47b77dc84075..49afcd5f6c4d5f 100644 --- a/lib/internal/http2/core.js +++ b/lib/internal/http2/core.js @@ -230,6 +230,7 @@ function debugSessionObj(session, message, ...args) { const kMaxFrameSize = (2 ** 24) - 1; const kMaxInt = (2 ** 32) - 1; +const kMaxInitialWindowSize = (2 ** 31) - 1; // HTTP/2 spec maximum const kMaxStreams = (2 ** 32) - 1; const kMaxALTSVC = (2 ** 14) - 2; @@ -989,7 +990,7 @@ function pingCallback(cb) { // Validates the values in a settings object. Specifically: // 1. headerTableSize must be a number in the range 0 <= n <= kMaxInt -// 2. initialWindowSize must be a number in the range 0 <= n <= kMaxInt +// 2. initialWindowSize must be a number in the range 0 <= n <= 2^31-1 // 3. maxFrameSize must be a number in the range 16384 <= n <= kMaxFrameSize // 4. maxConcurrentStreams must be a number in the range 0 <= n <= kMaxStreams // 5. maxHeaderListSize must be a number in the range 0 <= n <= kMaxInt @@ -1014,7 +1015,7 @@ const validateSettings = hideStackFrames((settings) => { 0, kMaxInt); assertWithinRange.withoutStackTrace('initialWindowSize', settings.initialWindowSize, - 0, kMaxInt); + 0, kMaxInitialWindowSize); assertWithinRange.withoutStackTrace('maxFrameSize', settings.maxFrameSize, 16384, kMaxFrameSize); diff --git a/test/parallel/test-http2-getpackedsettings.js b/test/parallel/test-http2-getpackedsettings.js index 05bf8eb6c1245d..d238eb8c7d1bf1 100644 --- a/test/parallel/test-http2-getpackedsettings.js +++ b/test/parallel/test-http2-getpackedsettings.js @@ -20,7 +20,7 @@ assert.deepStrictEqual(val, check); ['headerTableSize', 0], ['headerTableSize', 2 ** 32 - 1], ['initialWindowSize', 0], - ['initialWindowSize', 2 ** 32 - 1], + ['initialWindowSize', 2 ** 31 - 1], // Max per HTTP/2 spec ['maxFrameSize', 16384], ['maxFrameSize', 2 ** 24 - 1], ['maxConcurrentStreams', 0], @@ -42,6 +42,8 @@ http2.getPackedSettings({ enablePush: false }); ['headerTableSize', -1], ['headerTableSize', 2 ** 32], ['initialWindowSize', -1], + ['initialWindowSize', 2 ** 31], // Max per HTTP/2 spec is 2^31-1 + ['initialWindowSize', 2 ** 32 - 1], // Regression test for nghttp2 crash ['initialWindowSize', 2 ** 32], ['maxFrameSize', 16383], ['maxFrameSize', 2 ** 24], diff --git a/test/parallel/test-http2-session-settings.js b/test/parallel/test-http2-session-settings.js index 8d11e4c3b09371..f9511c4bde9662 100644 --- a/test/parallel/test-http2-session-settings.js +++ b/test/parallel/test-http2-session-settings.js @@ -133,6 +133,8 @@ server.listen( ['headerTableSize', -1], ['headerTableSize', 2 ** 32], ['initialWindowSize', -1], + ['initialWindowSize', 2 ** 31], // Max per HTTP/2 spec is 2^31-1 + ['initialWindowSize', 2 ** 32 - 1], // Regression test for nghttp2 crash ['initialWindowSize', 2 ** 32], ['maxFrameSize', 16383], ['maxFrameSize', 2 ** 24],