Uh oh!
There was an error while loading. Please reload this page.
Fix zlib pseudo multi member failure - #5863
Conversation
There was a problem hiding this comment.
Tiny style nit: can you put last clause on a separate line?
bnoordhuis
commented
Mar 23, 2016
Would it be possible to shrink the test fixtures? We distribute the test suite and they add another 128 kB. |
There was a problem hiding this comment.
If you're using path.join here it should be path.join(common.fixturesDir, 'pseudo-multimember-gzip'); rather than concat the strings.
6375567 to
84be337Compareaddaleax
commented
Mar 23, 2016
Updated with your suggestions. I’ll see what I can do about the file sizes – it’s just not that easy to get specific bytes at specific positions in gzipped files. 😄 |
84be337 to
74d56e0Compareaddaleax
commented
Mar 23, 2016
Okay, was easier than I thought, both files are now just a few hundred bytes together. |
bnoordhuis
commented
Mar 23, 2016
Nice, thanks. LGTM. CI: https://ci.nodejs.org/job/node-test-pull-request/2040/ |
There was a problem hiding this comment.
deepStrictEqual might be better?
There was a problem hiding this comment.
Sure, why not. Updated using assert.deepStrictEqual.
Fishrock123
commented
Mar 23, 2016
LGTM minus a nit, CI failure is unrelated. |
74d56e0 to
4e4c3c2CompareAdd test files that reliably reproduce nodejs#5852. The gzipped file in test/fixtures/pseudo-multimember-gzip.gz contains the gzip magic bytes exactly at the position that node encounters after having read a single block, leading it to believe that a new data member is starting.
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: nodejs#5852
4e4c3c2 to
1b2900fComparecjihrig
commented
Mar 23, 2016
LGTM |
jasnell
commented
Mar 23, 2016
LGTM |
kthelgason
commented
Mar 23, 2016
Wow, that was obvious in retrospect. Thanks! |
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. Add test files that reliably reproduce #5852. The gzipped file in test/fixtures/pseudo-multimember-gzip.gz contains the gzip magic bytes exactly at the position that node encounters after having read a single block, leading it to believe that a new data member is starting. Fixes: #5852 PR-URL: #5863 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Fishrock123
commented
Mar 23, 2016
Thanks! Landed in 0b3936b :) |
kthelgason
commented
Mar 23, 2016
@addaleax the other edge-case you mentioned, do you mean that another member is starting but less that 10 bytes remain in the input buffer? I think you're right that this might occur (although pretty unlikely). We only actually need to check if there are two bytes remaining, enough for the magic byte comparison. Then again even with that change, the edge-case still exists, albeit even less likely. If f.x. only one byte remains in the input buffer, in which case the output would be truncated anyway. |
addaleax
commented
Mar 24, 2016
@kthelgason Yes, that’s what I’m talking about. I’ll try and see whether I can get a test case for that together, but I agree, it’s definitely not very likely to occur in the wild. |
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. Add test files that reliably reproduce #5852. The gzipped file in test/fixtures/pseudo-multimember-gzip.gz contains the gzip magic bytes exactly at the position that node encounters after having read a single block, leading it to believe that a new data member is starting. Fixes: #5852 PR-URL: #5863 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Pull Request check-list
make -j8 test(UNIX) orvcbuild test nosign(Windows) pass withthis change (including linting)?
test (or a benchmark) included?
Affected core subsystem(s)
zlib
Description of change
Fixes#5852, which was introduced in f380db2 (#5120).
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.
I’m really not sure on whether “pseudo-multimember-gzip” & co. are the right names for the test files, but I don’t think there’s a specific term for this very situation. 😄
I’m also not sure whether the
ctx->strm_.avail_in >= GZIP_MIN_HEADER_SIZEcheck innode_zlib.ccdoesn’t open the possibility of another edge case, namely that there is a new gzip member starting, but not enough bytes have been read into the internal buffer. But that is very likely not related to #5852, since I assume it would result in truncated output rather than an error.