| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 63c601b commit afcd276
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -258,7 +258,8 @@ class ZCtx : public AsyncWrap { | |||
| 258 | 258 | } | |
| 259 | 259 | } | |
| 260 | 260 | while (ctx->strm_.avail_in >= GZIP_MIN_HEADER_SIZE && | |
| 261 | - ctx->mode_ == GUNZIP) { | ||
| 261 | + ctx->mode_ == GUNZIP && | ||
| 262 | + ctx->err_ == Z_STREAM_END) { | ||
| 262 | 263 | // Bytes remain in input buffer. Perhaps this is another compressed | |
| 263 | 264 | // member in the same archive, or just trailing garbage. | |
| 264 | 265 | // Check the header to find out. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4,6 +4,8 @@ | |||
| 4 | 4 | const common = require('../common'); | |
| 5 | 5 | const assert = require('assert'); | |
| 6 | 6 | const zlib = require('zlib'); | |
| 7 | + const path = require('path'); | ||
| 8 | + const fs = require('fs'); | ||
| 7 | 9 | ||
| 8 | 10 | const data = Buffer.concat([ | |
| 9 | 11 | zlib.gzipSync('abc'), | |
@@ -16,3 +18,23 @@ zlib.gunzip(data, common.mustCall((err, result) => { | |||
| 16 | 18 | assert.ifError(err); | |
| 17 | 19 | assert.equal(result, 'abcdef', 'result should match original string'); | |
| 18 | 20 | })); | |
| 21 | + | ||
| 22 | + // files that have the "right" magic bytes for starting a new gzip member | ||
| 23 | + // in the middle of themselves, even if they are part of a single | ||
| 24 | + // regularly compressed member | ||
| 25 | + const pmmFileZlib = path.join(common.fixturesDir, 'pseudo-multimember-gzip.z'); | ||
| 26 | + const pmmFileGz = path.join(common.fixturesDir, 'pseudo-multimember-gzip.gz'); | ||
| 27 | + | ||
| 28 | + const pmmExpected = zlib.inflateSync(fs.readFileSync(pmmFileZlib)); | ||
| 29 | + const pmmResultBuffers = []; | ||
| 30 | + | ||
| 31 | + fs.createReadStream(pmmFileGz) | ||
| 32 | + .pipe(zlib.createGunzip()) | ||
| 33 | + .on('error', (err) => { | ||
| 34 | + assert.ifError(err); | ||
| 35 | + }) | ||
| 36 | + .on('data', (data) => pmmResultBuffers.push(data)) | ||
| 37 | + .on('finish', common.mustCall(() => { | ||
| 38 | + assert.deepStrictEqual(Buffer.concat(pmmResultBuffers), pmmExpected, | ||
| 39 | + 'result should match original random garbage'); | ||
| 40 | + })); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments