Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v8.x] doc: more accurate zlib windowBits information #16623

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions doc/api/zlib.md
Original file line number Diff line number Diff line change
Expand Up @@ -459,12 +459,11 @@ added: v0.5.8
Creates and returns a new [DeflateRaw][] object with the given [options][].

*Note*: An upgrade of zlib from 1.2.8 to 1.2.11 changed behavior when windowBits
is set to 8 for raw deflate streams. zlib does not have a working implementation
of an 8-bit Window for raw deflate streams and would automatically set windowBit
to 9 if initially set to 8. Newer versions of zlib will throw an exception.
This creates a potential DOS vector, and as such the behavior has been reverted
in Node.js 8, 6, and 4. Node.js version 9 and higher will throw when windowBits
is set to 8.
is set to 8 for raw deflate streams. zlib would automatically set windowBits
to 9 if was initially set to 8. Newer versions of zlib will throw an exception,
so Node.js restored the original behavior of upgrading a value of 8 to 9,
since passing `windowBits = 9` to zlib actually results in a compressed stream
that effectively uses an 8-bit window only.

## zlib.createGunzip([options])
<!-- YAML
Expand Down
3 changes: 2 additions & 1 deletion test/parallel/test-zlib.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,8 @@ assert.doesNotThrow(() => {
// value of the matching deflate’s windowBits. However, inflate raw with
// windowBits = 8 should be able to handle compressed data from a source
// that does not know about the silent 8-to-9 upgrade of windowBits
// that older versions of zlib/Node perform.
// that most versions of zlib/Node perform, and which *still* results in
// a valid 8-bit-window zlib stream.
node.pipe(zlib.createDeflateRaw({ windowBits: 9 }))
.pipe(zlib.createInflateRaw({ windowBits: 8 }))
.on('data', (chunk) => reinflated.push(chunk))
Expand Down