GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — zlib: reject windowBits=8 when mode=GZIP · nodejs/node@736ca65

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • lib
    • zlib.js
  • test/parallel
    • test-zlib-failed-init.js
    • test-zlib-zero-windowBits.js
    • test-zlib.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎lib/zlib.js‎

Copy file name to clipboardExpand all lines: lib/zlib.js
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -613,9 +613,11 @@ function Zlib(opts, mode) {
613613
mode === UNZIP)) {
614614
windowBits = 0;
615615
} else {
616+
// `{ windowBits: 8 }` is valid for deflate but not gzip.
617+
const min = Z_MIN_WINDOWBITS + (mode === GZIP ? 1 : 0);
616618
windowBits = checkRangesOrGetDefault(
617619
opts.windowBits, 'options.windowBits',
618-
Z_MIN_WINDOWBITS, Z_MAX_WINDOWBITS, Z_DEFAULT_WINDOWBITS);
620+
min, Z_MAX_WINDOWBITS, Z_DEFAULT_WINDOWBITS);
619621
}
620622

621623
level = checkRangesOrGetDefault(
Collapse file

‎test/parallel/test-zlib-failed-init.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-zlib-failed-init.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ assert.throws(
2121
code: 'ERR_OUT_OF_RANGE',
2222
name: 'RangeError',
2323
message: 'The value of "options.windowBits" is out of range. It must ' +
24-
'be >= 8 and <= 15. Received 0'
24+
'be >= 9 and <= 15. Received 0'
2525
}
2626
);
2727

Collapse file

‎test/parallel/test-zlib-zero-windowBits.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-zlib-zero-windowBits.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@ const zlib = require('zlib');
2828
code: 'ERR_OUT_OF_RANGE',
2929
name: 'RangeError',
3030
message: 'The value of "options.windowBits" is out of range. ' +
31-
'It must be >= 8 and <= 15. Received 0'
31+
'It must be >= 9 and <= 15. Received 0'
3232
});
3333
}
Collapse file

‎test/parallel/test-zlib.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-zlib.js
+4-3Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,10 @@ const fixtures = require('../common/fixtures');
2929

3030
// Should not segfault.
3131
assert.throws(() => zlib.gzipSync(Buffer.alloc(0), { windowBits: 8 }), {
32-
code: 'ERR_ZLIB_INITIALIZATION_FAILED',
33-
name: 'Error',
34-
message: 'Initialization failed',
32+
code: 'ERR_OUT_OF_RANGE',
33+
name: 'RangeError',
34+
message: 'The value of "options.windowBits" is out of range. ' +
35+
'It must be >= 9 and <= 15. Received 8',
3536
});
3637

3738
let zlibPairs = [

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.