Repository navigation
zstd 0.14.5, zstd-safe 8.4.0, zstd-sys 2.2.0
This release bundles zstd 1.6.0, which fixes
CVE-2026-124851 and a
batch of memory-safety bugs (upstream release notes).
Updating is recommended. It also fixes three soundness issues in zstd-safe
(#401, #415, #416).
With pkg-config, the system's zstd library is used instead of the bundled
one: update it to 1.6.0 to get the upstream fixes.
Rust 1.64 remains supported.
zstd-sys 2.2.0+zstd.1.6.0
- Bundle zstd 1.6.0 (#420, thanks @emschwartz). It also fixes the wasm build
with zstd 1.6.0. - zstd 1.6.0 made these part of its stable API, so they no longer need the
experimentalfeature:ZSTD_getFrameHeader,ZSTD_FrameHeader,
ZSTD_FrameType_e,ZSTD_createDDict_byReference,
ZSTD_CCtx_loadDictionary_advanced,ZSTD_DCtx_loadDictionary_advanced,
ZSTD_dictContentType_eandZSTD_dictLoadMethod_e. experimental: zstd 1.6.0 removedZSTD_copyCCtxandZSTD_copyDCtx, and
addedZSTD_isDeterministicBuild.- zstd 1.6.0 disables legacy format support by default, but the
legacy
feature keeps working as before (on by default).
zstd-safe 8.4.0
New API:
get_frame_header()returns a frame's header (FrameHeader, zstd's own
struct), or how much of the frame it needs (FrameHeaderStatus).
get_frame_header_advanced()takes aFrameFormat(experimental).CCtx::load_dictionary_advanced()andDCtx::load_dictionary_advanced()
take aDictContentType.ref_dictionary()borrows the dictionary instead
of copying it.DDict::create_by_reference()no longer needsexperimental.- Worker threads with owned data:
CCtx::set_cdict(),CCtx::set_prefix(),
CCtx::compress_with_cdict(),CCtx::compress_with_prefix(),
CDict::create_by_reference_owned()(experimental), and
CCtx::frame_workers(), which tells how many workers a frame gets.
Fixes:
- Leaking a
CCtxin the middle of a multithreaded frame that reads a
borrowed dictionary or prefix no longer lets the workers read it after the
borrow ends (#401, #411). - The block API no longer reads memory that an earlier one-shot call only
borrowed, or state zstd never set up (#415, #417). NoOpno longer writes through a stale pointer when aWriteBuf's
capacity changes between calls (#416, #417).- Worker tracking stays in step with zstd: in
compress2()when the
destination panics, with stale pledged sizes, and with clamped
NbWorkers(#407). - One-shot calls end their session before the
WriteBufruns, so a
panicking destination no longer leaves the context pointing at borrowed
buffers (#409).
Behaviour changes:
- With worker threads, a streaming frame that reads borrowed data (a prefix
fromref_prefix(), aCDictmade bycreate_by_reference(), a dictionary
fromref_dictionary()) runs on the calling thread, andJobSize,
OverlapSizeLogandRSyncablehave no effect on it.compress2()and
the owned variants above keep the workers. NbWorkersis refused (parameter_unsupported) without thezstdmt
feature, even when the linked zstd library has threads.zstdmtnow
enablesalloc.compress_block()/decompress_block()run in block sessions of their
own: any other&mut selfmethod ends the session, and a failed block
call poisons the context until a reset.WriteBuf's contract now says its capacity and pointer must not change
while zstd-safe uses the buffer (they may between uses, as aVec's
does). Every implementation in this crate already did; check your own
unsafe impl WriteBuf.
zstd 0.14.5
DecoderDictionary::new()andtry_new()no longer needexperimental.EncoderDictionaryisClone, andEncoderDictionary::from_cdict()wraps
any prepared dictionary. Encoders and compressors keep their own handle, so
with_prepared_dictionary()only needs the dictionary's bytes to outlive
them.write::Encoder::with_prefix()takes a prefix the encoder owns, and
bulk::Compressor::compress_with_prefix()borrows one for a single call:
both keep the worker threads.- Out of memory: failing to allocate a compression context now returns an
OutOfMemoryerror instead of panicking. The decoders report
OutOfMemory(they saidOther), and so does zstd's own
memory_allocationerror, which no longer carries azstd::Error. None
of these errors allocate (#414, thanks @gleocadie, and #418). write::Encoderno longer writes a second, empty frame when flushed while
a finish is being retried. Behaviour change:write()in that state
returns the "encoder is finished" error (#404).AutoFinishEncoderandAutoFlushDecoderno longer abort the process
when the writer or callback panics while another panic unwinds (#404).
Upgrading with the experimental feature
zstd-safe up to 8.2 has CCtx::try_clone() and DCtx::try_clone() behind
experimental, and they call the functions zstd 1.6.0 removed: with
experimental, those versions no longer build against zstd-sys 2.2.0.
Update to zstd-safe 8.4.0 (zstd 0.14.5), or stay on the previous zstd-sys
with cargo update -p zstd-sys --precise 2.1.3+zstd.1.5.7.
The same applies to the 0.13 line: zstd 0.13 picks up zstd-sys 2.2.0 (and
zstd 1.6.0) on cargo update, except with experimental.