diff options
author | Tarjei Husøy <git@thusoy.com> | 2016-09-20 11:43:07 -0700 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2016-09-20 23:05:35 +0200 |
commit | c775514e56e5e20e93c168e679b84c13f2e739b5 (patch) | |
tree | bf7379c8c6fd708bebe1b54bb9a8ec5f404fc615 /test/parallel/test-zlib-dictionary-fail.js | |
parent | 4019c321d4b080269165d5ec1c753238a641bc4a (diff) | |
download | android-node-v8-c775514e56e5e20e93c168e679b84c13f2e739b5.tar.gz android-node-v8-c775514e56e5e20e93c168e679b84c13f2e739b5.tar.bz2 android-node-v8-c775514e56e5e20e93c168e679b84c13f2e739b5.zip |
zlib: fix raw inflate with custom dictionary
Moves inflateSetDictionary right after inflateInit2 when mode is
INFLATERAW, since without the wrapper in appears zlib won't return
Z_NEED_DICT as it would otherwise, and will thus attempt inflating
without the dictionary, leading to an error.
Fixes: https://github.com/nodejs/node/issues/8507
PR-URL: https://github.com/nodejs/node/pull/8512
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'test/parallel/test-zlib-dictionary-fail.js')
-rw-r--r-- | test/parallel/test-zlib-dictionary-fail.js | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/test/parallel/test-zlib-dictionary-fail.js b/test/parallel/test-zlib-dictionary-fail.js index 52f295157b..822ca1f028 100644 --- a/test/parallel/test-zlib-dictionary-fail.js +++ b/test/parallel/test-zlib-dictionary-fail.js @@ -26,3 +26,17 @@ const zlib = require('zlib'); // String "test" encoded with dictionary "dict". stream.write(Buffer.from([0x78, 0xBB, 0x04, 0x09, 0x01, 0xA5])); } + +// Should raise an error, not trigger an assertion in src/node_zlib.cc +{ + const stream = zlib.createInflateRaw({ dictionary: Buffer.from('fail') }); + + stream.on('error', common.mustCall(function(err) { + // It's not possible to separate invalid dict and invalid data when using + // the raw format + assert(/invalid/.test(err.message)); + })); + + // String "test" encoded with dictionary "dict". + stream.write(Buffer.from([0x78, 0xBB, 0x04, 0x09, 0x01, 0xA5])); +} |