GeezerVison is showing github.com — zlib: reject windowBits=8 when mode=GZIP · nodejs/node@736ca65
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: lib/zlib.js +3-1Lines changed: 3 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -613,9 +613,11 @@ function Zlib(opts, mode) { | 613 | 613 | mode === UNZIP)) { | 614 | 614 | windowBits = 0; | 615 | 615 | } else { | | 616 | + // `{ windowBits: 8 }` is valid for deflate but not gzip. | | 617 | + const min = Z_MIN_WINDOWBITS + (mode === GZIP ? 1 : 0); | 616 | 618 | windowBits = checkRangesOrGetDefault( | 617 | 619 | opts.windowBits, 'options.windowBits', | 618 | | - Z_MIN_WINDOWBITS, Z_MAX_WINDOWBITS, Z_DEFAULT_WINDOWBITS); | | 620 | + min, Z_MAX_WINDOWBITS, Z_DEFAULT_WINDOWBITS); | 619 | 621 | } | 620 | 622 |
| 621 | 623 | level = checkRangesOrGetDefault( | |
Collapse file Copy file name to clipboardExpand all lines: test/parallel/test-zlib-failed-init.js +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -21,7 +21,7 @@ assert.throws( | 21 | 21 | code: 'ERR_OUT_OF_RANGE', | 22 | 22 | name: 'RangeError', | 23 | 23 | 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' | 25 | 25 | } | 26 | 26 | ); | 27 | 27 |
| |
Collapse file Copy file name to clipboardExpand all lines: test/parallel/test-zlib-zero-windowBits.js +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -28,6 +28,6 @@ const zlib = require('zlib'); | 28 | 28 | code: 'ERR_OUT_OF_RANGE', | 29 | 29 | name: 'RangeError', | 30 | 30 | 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' | 32 | 32 | }); | 33 | 33 | } |
Collapse file Copy file name to clipboardExpand all lines: test/parallel/test-zlib.js +4-3Lines changed: 4 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -29,9 +29,10 @@ const fixtures = require('../common/fixtures'); | 29 | 29 |
| 30 | 30 | // Should not segfault. | 31 | 31 | 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', | 35 | 36 | }); | 36 | 37 |
| 37 | 38 | let zlibPairs = [ | |
|