Skip to content
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

zstd_safe::DCtx::decompress_stream may result in UB #315

Open
vilgotf opened this issue Dec 26, 2024 · 1 comment
Open

zstd_safe::DCtx::decompress_stream may result in UB #315

vilgotf opened this issue Dec 26, 2024 · 1 comment

Comments

@vilgotf
Copy link

vilgotf commented Dec 26, 2024

The decompress_stream method internally calls ZSTD_decompressStream which has the following note:

Note: when an operation returns with an error code, the zds state may be left in undefined state.
It's UB to invoke ZSTD_decompressStream() on such a state.
In order to re-use such a state, it must be first reset,
which can be done explicitly (ZSTD_DCtx_reset()),
or is implied for operations starting some new decompression job (ZSTD_initDStream, ZSTD_decompressDCtx(), ZSTD_decompress_usingDict())

This is not enforced by zstd-safe and is left for callers to handle. The method must either be unsafe or error/panic when called on undefined state.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
@vilgotf and others