Skip to content

zlib: reject trailing gzip members in web streams#64023

Open
panva wants to merge 3 commits into
nodejs:mainfrom
panva:fix-decompressionstream-trailing-data
Open

zlib: reject trailing gzip members in web streams#64023
panva wants to merge 3 commits into
nodejs:mainfrom
panva:fix-decompressionstream-trailing-data

Conversation

@panva

@panva panva commented Jun 20, 2026

Copy link
Copy Markdown
Member

Pass the existing rejectGarbageAfterEnd option through to the native zlib context and skip gunzip's concatenated-member loop when it is set. This lets DecompressionStream reject a second gzip member as trailing input while preserving default zlib gunzip behavior.

Also make the sync zlib path honor rejectGarbageAfterEnd when native decompression leaves unused input, covering Brotli as well.

Fixes: #58247


Document rejectGarbageAfterEnd as a public decompression option and validate it as a boolean.

Add coverage for stream, async convenience, and sync convenience APIs across zlib, gzip, Brotli, and Zstd-backed decompression.

Pass the existing rejectGarbageAfterEnd option through to the native
zlib context and skip gunzip's concatenated-member loop when it is set.
This lets DecompressionStream reject a second gzip member as trailing
input while preserving default zlib gunzip behavior.

Also make the sync zlib path honor rejectGarbageAfterEnd when native
decompression leaves unused input, covering Brotli as well.

Fixes: nodejs#58247

Signed-off-by: Filip Skokan <panva.ip@gmail.com>
@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run. zlib Issues and PRs related to the zlib subsystem. labels Jun 20, 2026
@panva panva requested a review from ChALkeR June 20, 2026 10:56
@panva panva added the commit-queue-rebase Add this label to allow the Commit Queue to land a PR in several commits. label Jun 20, 2026
@panva panva force-pushed the fix-decompressionstream-trailing-data branch from 88f47d2 to 481083c Compare June 20, 2026 11:12
Document rejectGarbageAfterEnd as a public decompression option and
validate it as a boolean.

Add coverage for stream, async convenience, and sync convenience APIs
across zlib, gzip, Brotli, and Zstd-backed decompression.

Signed-off-by: Filip Skokan <panva.ip@gmail.com>
@panva panva force-pushed the fix-decompressionstream-trailing-data branch from 481083c to a47d32d Compare June 20, 2026 11:13
Comment thread doc/api/zlib.md Outdated
@panva panva added author ready PRs that have at least one approval, no pending requests for changes, and a CI started. request-ci Add this label to start a Jenkins CI on a PR. labels Jun 22, 2026
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jun 22, 2026
@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author ready PRs that have at least one approval, no pending requests for changes, and a CI started. c++ Issues and PRs that require attention from people who are familiar with C++. commit-queue-rebase Add this label to allow the Commit Queue to land a PR in several commits. needs-ci PRs that need a full CI run. 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