Skip to content

lib: reject ZSTD_decompressContinue() without ZSTD_decompressBegin() - #4937

Open
Cyan4973 wants to merge 1 commit into
devfrom
dctx-continue-without-begin
Open

Cyan4973 wants to merge 1 commit into
devfrom
dctx-continue-without-begin

Conversation

@Cyan4973

Copy link
Copy Markdown
Contributor

ZSTD_decompressContinue() requires ZSTD_decompressBegin() before each frame, as documented in #4933, but nothing enforced it.
After a finished frame, ZSTD_decompressContinue(dctx, dst, cap, src, 0) passed the size check and read 4 bytes from src: a heap overflow under ASan, a segfault when src is NULL.
On a new DCtx, stage and expected were not initialized at all.

ZSTD_initDCtx_internal() now initializes them, and ZSTD_decompressContinue() returns stage_wrong in both cases.

After a finished frame, ZSTD_decompressContinue() accepted srcSize == 0
and read 4 bytes from src, crashing when src is NULL.
A new DCtx left the decoder state uninitialized.
Both cases now return stage_wrong.
@meta-cla meta-cla Bot added the CLA Signed label Nov 12, 2026
@Cyan4973 Cyan4973 self-assigned this Nov 12, 2026

This branch has not been deployed

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants