Skip to content

Commit

Permalink
zlib: Fix handling of gzip magic bytes mid-file
Browse files Browse the repository at this point in the history
Only treat the gzip magic bytes, when encountered within the file
after reading a single block, as the start of a new member when
the previous member has ended.

Fixes: #5852
  • Loading branch information
addaleax committed Mar 23, 2016
1 parent 2dd5945 commit 1b2900f
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/node_zlib.cc
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,8 @@ class ZCtx : public AsyncWrap {
}
}
while (ctx->strm_.avail_in >= GZIP_MIN_HEADER_SIZE &&
ctx->mode_ == GUNZIP) {
ctx->mode_ == GUNZIP &&
ctx->err_ == Z_STREAM_END) {
// Bytes remain in input buffer. Perhaps this is another compressed
// member in the same archive, or just trailing garbage.
// Check the header to find out.
Expand Down

0 comments on commit 1b2900f

Please sign in to comment.