Skip to content

Commit 44c0385

Browse files
addaleaxMylesBorins
authored andcommitted
doc: more accurate zlib windowBits information
Fixes: #14847 PR-URL: #16511 Backport-PR-URL: #16623 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Refael Ackermann <refack@gmail.com>
1 parent 732af9b commit 44c0385

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

doc/api/zlib.md

+5-6
Original file line numberDiff line numberDiff line change
@@ -423,12 +423,11 @@ added: v0.5.8
423423
Returns a new [DeflateRaw][] object with an [options][].
424424

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

433432
## zlib.createGunzip([options])
434433
<!-- YAML

test/parallel/test-zlib.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,8 @@ assert.doesNotThrow(() => {
145145
// value of the matching deflate’s windowBits. However, inflate raw with
146146
// windowBits = 8 should be able to handle compressed data from a source
147147
// that does not know about the silent 8-to-9 upgrade of windowBits
148-
// that older versions of zlib/Node perform.
148+
// that most versions of zlib/Node perform, and which *still* results in
149+
// a valid 8-bit-window zlib stream.
149150
node.pipe(zlib.createDeflateRaw({ windowBits: 9 }))
150151
.pipe(zlib.createInflateRaw({ windowBits: 8 }))
151152
.on('data', (chunk) => reinflated.push(chunk))

0 commit comments

Comments
 (0)