Skip to content

zlib: add error handling for trailing junk after stream end #58316

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

0hmX
Copy link
Contributor

@0hmX 0hmX commented May 13, 2025

Close #58247

Introduce ERR_TRAILING_JUNK_AFTER_STREAM_END error to handle unexpected data after the end of a compressed stream. This ensures proper error reporting when decompressing deflate or gzip streams with trailing junk. Added tests to verify the behavior.

@nodejs-github-bot nodejs-github-bot added errors Issues and PRs related to JavaScript errors originated in Node.js core. needs-ci PRs that need a full CI run. web streams zlib Issues and PRs related to the zlib subsystem. labels May 13, 2025
@0hmX 0hmX force-pushed the DecompressionStream branch 2 times, most recently from 138710a to 002c166 Compare May 13, 2025 18:26
@0hmX 0hmX changed the title feat(zlib): add error handling for trailing junk after stream end zlib: add error handling for trailing junk after stream end May 13, 2025
Introduce `ERR_TRAILING_JUNK_AFTER_STREAM_END` error to
handle unexpected data after the end of a compressed stream.
This ensures proper error reporting when decompressing
deflate or gzip streams with trailing junk.
Added tests to verify the behavior.

Fixes: nodejs#58247
@0hmX 0hmX force-pushed the DecompressionStream branch from 002c166 to 90e4081 Compare May 13, 2025 18:59
Copy link

codecov bot commented May 13, 2025

Codecov Report

Attention: Patch coverage is 85.71429% with 4 lines in your changes missing coverage. Please review.

Project coverage is 90.23%. Comparing base (dc7ec42) to head (b43863c).
Report is 47 commits behind head on main.

Files with missing lines Patch % Lines
lib/internal/webstreams/compression.js 71.42% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #58316      +/-   ##
==========================================
+ Coverage   90.18%   90.23%   +0.04%     
==========================================
  Files         629      633       +4     
  Lines      186641   186845     +204     
  Branches    36654    36680      +26     
==========================================
+ Hits       168329   168599     +270     
+ Misses      11112    11042      -70     
- Partials     7200     7204       +4     
Files with missing lines Coverage Δ
lib/internal/errors.js 97.47% <100.00%> (+<0.01%) ⬆️
lib/zlib.js 98.24% <100.00%> (+0.02%) ⬆️
lib/internal/webstreams/compression.js 97.68% <71.42%> (-2.32%) ⬇️

... and 64 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@0hmX 0hmX marked this pull request as draft May 15, 2025 13:46
0hmX added 2 commits May 15, 2025 21:25
…ive.any.js

All subtests in decompression-corrupt
input.tentative.any.js now pass,
so the "fail.expected" entry has been
removed from the status file.
This reflects the current passing
state of the test suite.
Corrected the formatting of the
`ERR_TRAILING_JUNK_AFTER_STREAM_END` section by
removing trailing spaces and ensuring consistent
line breaks for better readability.
@0hmX 0hmX marked this pull request as ready for review May 15, 2025 16:04
@0hmX
Copy link
Contributor Author

0hmX commented May 15, 2025

requesting review @jasnell @ChALkeR

@bjohansebas
Copy link
Member

cc: @nodejs/zlib

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
errors Issues and PRs related to JavaScript errors originated in Node.js core. needs-ci PRs that need a full CI run. web streams zlib Issues and PRs related to the zlib subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DecompressionStream should not accept data after the end
3 participants