GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — zlib: support concatenated archives by kthelgason · Pull Request #5120 · nodejs/node

Conversation

@kthelgason

@kthelgason kthelgason commented Feb 6, 2016

Copy link
Copy Markdown
Contributor

This PR adds support for gunzipping archives that consists of multiple concatenated members.
This has not been supported by node's implementation so far but is a part of the spec rfc1952.

The problem was raised in #4306, and there is more detailed discussion on this feature in the issue.

I also refactored some of lib/zlib.js but I will submit that in a separate PR later.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@kthelgason
kthelgason force-pushed the zlib-concatenated-archives branch 2 times, most recently from 267b15e to 017e172 Compare February 6, 2016 15:26
@Fishrock123 Fishrock123 added zlib Issues and PRs related to the zlib module and its compression dependencies. semver-minor PRs that contain new features and should be released in the next minor version. labels Feb 6, 2016
@Fishrock123

Fishrock123 commented Feb 6, 2016

Copy link
Copy Markdown
Contributor

cc @indutny or @bnoordhuis

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

bnoordhuis
bnoordhuis reviewed Feb 6, 2016
View reviewed changes
Comment thread src/node_zlib.cc Outdated

@bnoordhuis bnoordhuis Feb 6, 2016

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Magic constants need an explaining comment and should preferably be true, well-named constants.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@kthelgason kthelgason Feb 6, 2016

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I thought this was a little silly. It should probably check to make sure that avail_in is at least equal to the gzip header size. I'll fix this.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@kthelgason

kthelgason commented Feb 6, 2016

Copy link
Copy Markdown
Contributor Author

Thanks for the review @bnoordhuis. I've addressed some individual comments and will be updating this PR to fix all the issues mentioned.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bnoordhuis

bnoordhuis commented Feb 6, 2016

Copy link
Copy Markdown
Member

Can you post a comment when you're done? GH doesn't send notifications for new or updated commits.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@kthelgason
kthelgason force-pushed the zlib-concatenated-archives branch from 017e172 to 30be769 Compare February 6, 2016 21:17
@kthelgason

kthelgason commented Feb 6, 2016

Copy link
Copy Markdown
Contributor Author

I've updated this in line with the comments from @bnoordhuis.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

bnoordhuis
bnoordhuis reviewed Feb 7, 2016
View reviewed changes
Comment thread src/node_zlib.cc Outdated

@bnoordhuis bnoordhuis Feb 7, 2016

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a little more idiomatic to write it as ctx->strm_.next_in[1] != GZIP_HEADER_ID2. Suggestion: use indexed notation for the first byte too, for consistency; that's what we do elsewhere.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bnoordhuis

bnoordhuis commented Feb 7, 2016

Copy link
Copy Markdown
Member

LGTM with a style nit. Perhaps it would be good to add a test for an archive that looks like an concatenated archive but isn't, i.e., with trailing junk that just happens to start with the right magic bytes.

CI: https://ci.nodejs.org/job/node-test-pull-request/1580/ (currently private)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@kthelgason

kthelgason commented Feb 7, 2016

Copy link
Copy Markdown
Contributor Author

I thought about including such a test, but it's pretty unclear to me what the expected behaviour is. Technically, trailing garbage in a gzipped file is forbidden by the spec. It seems however that in practice some files are padded with '\0', and I've accounted for this in my implementation. Currently, if a file happens to contain trailing garbage that happens to begin with the gzip header id bytes it will not decompress correctly and an error will be thrown.
I felt this was ok as the archive is technically invalid.

EDIT: I just checked if gzip(1) supports this and it throws an error in this situation. Seeing as it's cited by the RFC as a reference implementation I think we should adopt that behaviour as well.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@kthelgason
kthelgason force-pushed the zlib-concatenated-archives branch from 30be769 to 30f5b38 Compare February 7, 2016 19:27
@kthelgason

kthelgason commented Feb 7, 2016

Copy link
Copy Markdown
Contributor Author

Addressed the style nit and force pushed.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Fishrock123

Fishrock123 commented Feb 7, 2016

Copy link
Copy Markdown
Contributor

@kthelgason About the trailing \0 thing -- does this change the behavior of that from the current one?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@kthelgason

kthelgason commented Feb 7, 2016

Copy link
Copy Markdown
Contributor Author

@Fishrock123 no, both implementations simply ignore the junk bytes at the end.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Fishrock123

Fishrock123 commented Feb 7, 2016

Copy link
Copy Markdown
Contributor

@kthelgason Seems fine to me then; let's discuss the trailing bytes thing in a different issue if it is important.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

thefourtheye
thefourtheye reviewed Feb 7, 2016
View reviewed changes
Comment thread test/parallel/test-zlib-from-concatenated-gzip.js Outdated

@thefourtheye thefourtheye Feb 7, 2016

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't ignore the error. You can do assert.ifError

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@targos targos Feb 7, 2016

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need to wrap this kind of callback in common.mustCall to make sure the assertions are really executed?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@Fishrock123 Fishrock123 Feb 7, 2016

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's why common.mustCall exists! :)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@kthelgason
kthelgason force-pushed the zlib-concatenated-archives branch from 30f5b38 to f7b67e4 Compare February 7, 2016 20:28
@kthelgason

kthelgason commented Feb 7, 2016

Copy link
Copy Markdown
Contributor Author

@thefourtheye @targos @Fishrock123 fixed.

Regarding the trailing garbage bytes, I think opening another issue to discuss that (if necessary) would be a good idea.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jasnell

jasnell commented Feb 7, 2016

Copy link
Copy Markdown
Member

LGTM

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bnoordhuis

bnoordhuis commented Feb 7, 2016

Copy link
Copy Markdown
Member

LGTM. Is there much to discuss w.r.t. trailing garbage? Emitting an error is the obvious thing to do, right?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@kthelgason

kthelgason commented Feb 7, 2016

Copy link
Copy Markdown
Contributor Author

@bnoordhuis to me it seems that way yes. Esp. given that gzip(1) handles it that way.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bnoordhuis

bnoordhuis commented Feb 7, 2016

Copy link
Copy Markdown
Member

Exactly. I'd add the test case to this PR. Might as well land it with full coverage from the start.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@kthelgason

kthelgason commented Mar 14, 2016

Copy link
Copy Markdown
Contributor Author

Thanks for the comment @rvagg and for the review @bnoordhuis. I've squashed the commits as recommended, and CI looks good (apart from the ARM failure but as pointed out by @jbergstroem I can't see that it's related to this at all).

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bnoordhuis

bnoordhuis commented Mar 15, 2016

Copy link
Copy Markdown
Member

Thanks Kári, landed in f380db2.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bnoordhuis bnoordhuis closed this Mar 15, 2016
bnoordhuis pushed a commit that referenced this pull request Mar 15, 2016
@kthelgason @bnoordhuis
zlib: add support for concatenated members
f380db2
According to the spec gzipped archives can contain more than one
compressed member. Previously Node's gzip implementation would only
unzip the first member and throw away the rest of the compressed data.
Issue #4306 is an example of this occurring in daily use.

Fixes: #4306
PR-URL: #5120
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: James M Snell <[email protected]>
@kthelgason
kthelgason deleted the zlib-concatenated-archives branch March 15, 2016 17:12
evanlucas pushed a commit that referenced this pull request Mar 15, 2016
@kthelgason @evanlucas
zlib: add support for concatenated members
287ea7a
According to the spec gzipped archives can contain more than one
compressed member. Previously Node's gzip implementation would only
unzip the first member and throw away the rest of the compressed data.
Issue #4306 is an example of this occurring in daily use.

Fixes: #4306
PR-URL: #5120
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: James M Snell <[email protected]>
evanlucas added a commit that referenced this pull request Mar 15, 2016
@evanlucas
2016-03-14, Version 5.8.1 (Stable)
b94cacf
Notable changes:

* **governance**: The following members have been added as collaborators:
  - Andreas Madsen (@AndreasMadsen)
  - Benjamin Gruenbaum (@benjamingr)
  - Claudio Rodriguez (@claudiorodriguez)
  - Glen Keane (@thekemkid)
  - Jeremy Whitlock (@whitlockjc)
  - Matt Loring (@matthewloring)
  - Phillip Johnsen (@phillipj)
* **lib**: copy arguments object instead of leaking it (Nathan Woltman) #4361
* **zlib**: add support for concatenated members (Kári Tristan Helgason) #5120

PR-URL: #5702
@evanlucas evanlucas mentioned this pull request Mar 15, 2016
v5.9.0 proposal #5702
Merged
rvagg pushed a commit that referenced this pull request Mar 16, 2016
@kthelgason @rvagg
zlib: add support for concatenated members
ef774ff
According to the spec gzipped archives can contain more than one
compressed member. Previously Node's gzip implementation would only
unzip the first member and throw away the rest of the compressed data.
Issue #4306 is an example of this occurring in daily use.

Fixes: #4306
PR-URL: #5120
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: James M Snell <[email protected]>
evanlucas added a commit that referenced this pull request Mar 16, 2016
@evanlucas
2016-03-16, Version 5.9.0 (Stable)
da46edb
Notable changes:

* **governance**: The following members have been added as
collaborators:
  - Andreas Madsen (@AndreasMadsen)
  - Benjamin Gruenbaum (@benjamingr)
  - Claudio Rodriguez (@claudiorodriguez)
  - Glen Keane (@thekemkid)
  - Jeremy Whitlock (@whitlockjc)
  - Matt Loring (@matthewloring)
  - Phillip Johnsen (@phillipj)
* **lib**: copy arguments object instead of leaking it (Nathan Woltman)
#4361
* **zlib**: add support for concatenated members (Kári Tristan
Helgason) #5120

PR-URL: #5702
evanlucas added a commit that referenced this pull request Mar 16, 2016
@evanlucas
2016-03-16, Version 5.9.0 (Stable)
a08ac52
Notable changes:

* **governance**: The following members have been added as
collaborators:
  - Andreas Madsen (@AndreasMadsen)
  - Benjamin Gruenbaum (@benjamingr)
  - Claudio Rodriguez (@claudiorodriguez)
  - Glen Keane (@thekemkid)
  - Jeremy Whitlock (@whitlockjc)
  - Matt Loring (@matthewloring)
  - Phillip Johnsen (@phillipj)
* **lib**: copy arguments object instead of leaking it (Nathan Woltman)
#4361
* **src**: allow combination of -i and -e cli flags (Rich Trott)
#5655
* **zlib**: add support for concatenated members (Kári Tristan
Helgason) #5120

PR-URL: #5702
evanlucas added a commit that referenced this pull request Mar 16, 2016
@evanlucas
2016-03-16, Version 5.9.0 (Stable)
79cb1a9
Notable changes:

* **contextify**: Fixed a memory consumption issue related to heavy use
of `vm.createContext` and `vm.runInNewContext`. (Ali Ijaz Sheikh)
#5392
* **governance**: The following members have been added as
collaborators:
  - Andreas Madsen (@AndreasMadsen)
  - Benjamin Gruenbaum (@benjamingr)
  - Claudio Rodriguez (@claudiorodriguez)
  - Glen Keane (@thekemkid)
  - Jeremy Whitlock (@whitlockjc)
  - Matt Loring (@matthewloring)
  - Phillip Johnsen (@phillipj)
* **lib**: copy arguments object instead of leaking it (Nathan Woltman)
#4361
* **src**: allow combination of -i and -e cli flags (Rich Trott)
#5655
* **v8**: backport fb4ccae from v8 upstream (Vladimir Krivosheev) #4231
  -  breakout events from v8 to offer better support for external
     debuggers
* **zlib**: add support for concatenated members (Kári Tristan
Helgason) #5120

PR-URL: #5702
evanlucas added a commit that referenced this pull request Mar 16, 2016
@evanlucas
2016-03-16, Version 5.9.0 (Stable)
e7039db
Notable changes:

* **contextify**: Fixed a memory consumption issue related to heavy use
of `vm.createContext` and `vm.runInNewContext`. (Ali Ijaz Sheikh)
#5392
* **governance**: The following members have been added as
collaborators:
  - Andreas Madsen (@AndreasMadsen)
  - Benjamin Gruenbaum (@benjamingr)
  - Claudio Rodriguez (@claudiorodriguez)
  - Glen Keane (@thekemkid)
  - Jeremy Whitlock (@whitlockjc)
  - Matt Loring (@matthewloring)
  - Phillip Johnsen (@phillipj)
* **lib**: copy arguments object instead of leaking it (Nathan Woltman)
#4361
* **src**: allow combination of -i and -e cli flags (Rich Trott)
#5655
* **v8**: backport fb4ccae from v8 upstream (Vladimir Krivosheev) #4231
  -  breakout events from v8 to offer better support for external
     debuggers
* **zlib**: add support for concatenated members (Kári Tristan
Helgason) #5120

PR-URL: #5702
@jasnell jasnell mentioned this pull request Mar 22, 2016
zlib.createGunzip "unknown compression method" #5852
Closed
@addaleax addaleax mentioned this pull request Mar 23, 2016
Fix zlib pseudo multi member failure #5863
Closed
3 tasks done
@tstanev tstanev mentioned this pull request Mar 23, 2016
Regression in gunzip in 5.9.0 -- GZ files that used to uncompress no longer do #5871
Closed
This was referenced Mar 24, 2016
zlib: Allow zlib.gunzip features with zlib.unzip #5884
Closed
zlib: Fix gzip member header/input buffer boundary issue #5883
Closed
@addaleax addaleax mentioned this pull request Apr 8, 2016
ZLIB failing to inflate entire .gz file that contains an extra field in the header #6116
Closed
@jacobischwartz jacobischwartz mentioned this pull request Apr 25, 2017
Only opens first few ALB logs when using Node 4.6 amazon-archives/cloudwatch-logs-centralize-logs#4
Open
@vmarkovtsev vmarkovtsev mentioned this pull request Aug 30, 2024
Cannot load a gzipped JSON trace with multiple blocks google/perfetto#872
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

semver-minor PRs that contain new features and should be released in the next minor version. zlib Issues and PRs related to the zlib module and its compression dependencies.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

8 participants

@kthelgason @Fishrock123 @bnoordhuis @jasnell @rvagg @jbergstroem @thefourtheye @targos
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.