aboutsummaryrefslogtreecommitdiff
path: root/lib/std/compress/zstd
AgeCommit message (Collapse)Author
2025-09-02zstd.Decompress: Assert buffer length requirements as early as possibleRyan Liptak
Without this assert, providing a buffer that's smaller than required results in more cryptic assertion failures later on.
2025-08-29std.Io: delete GenericReaderAndrew Kelley
and delete deprecated alias std.io
2025-08-15zstd: Protect against index out-of-bounds when decoding sequencesRyan Liptak
Previously, index out-of-bounds could occur when copying match_length bytes while decoding whatever sequence happened to overflow `dest`. Now, each sequence checks that there is enough room for the full sequence_length (literal_length + match_length) before doing any copying. Fixes the failing inputs found here: https://github.com/ziglang/zig/issues/24817#issuecomment-3192927715
2025-08-15std.compress.zstd.Decompress fixesAndrew Kelley
* std.Io.Reader: appendRemaining no longer supports alignment and has different rules about how exceeding limit. Fixed bug where it would return success instead of error.StreamTooLong like it was supposed to. * std.Io.Reader: simplify appendRemaining and appendRemainingUnlimited to be implemented based on std.Io.Writer.Allocating * std.Io.Writer: introduce unreachableRebase * std.Io.Writer: remove minimum_unused_capacity from Allocating. maybe that flexibility could have been handy, but let's see if anyone actually needs it. The field is redundant with the superlinear growth of ArrayList capacity. * std.Io.Writer: growingRebase also ensures total capacity on the preserve parameter, making it no longer necessary to do ensureTotalCapacity at the usage site of decompression streams. * std.compress.flate.Decompress: fix rebase not taking into account seek * std.compress.zstd.Decompress: split into "direct" and "indirect" usage patterns depending on whether a buffer is provided to init, matching how flate works. Remove some overzealous asserts that prevented buffer expansion from within rebase implementation. * std.zig: fix readSourceFileToAlloc returning an overaligned slice which was difficult to free correctly. fixes #24608
2025-08-14zstd.Decompress.stream: Fix handling of skippable frames in new_frame stateRyan Liptak
The previous code assumed that `initFrame` during the `new_frame` state would always result in the `in_frame` state, but that's not always the case. `initFrame` can also result in the `skippable_frame` state, which would lead to access of union field 'in_frame' while field 'skipping_frame' is active. Now, the switch is re-entered with the updated state so either case is handled appropriately. Fixes the crashes from https://github.com/ziglang/zig/issues/24817
2025-08-14zstd.Decompress: Delete unused/impossible "end" stateRyan Liptak
2025-08-14zstd.Decompress: Treat a partial magic number as a failureRyan Liptak
Previously, the "allow EndOfStream" part of this logic was too permissive. If there are a few dangling bytes at the end of the stream, that should be treated as a bad magic number. The only case where EndOfStream is allowed is when the stream is truly at the end, with exactly zero bytes available.
2025-07-31std.compress: fix discard impl and flate error detectionAndrew Kelley
2025-07-31std: match readVec fn prototype exactlyAndrew Kelley
this is not necessary according to zig language, but works around a flaw in the C backend
2025-07-31std.compress.zstd.Decompress: implement discard and readVecAndrew Kelley
2025-07-30std.Io.Reader: introduce readVec back into the VTableAndrew Kelley
simplifies and fixes things addresses a subset of #24608
2025-07-29std.Io.Reader: make fillUnbuffered respect prexisting bufferAndrew Kelley
addresses only one usage pattern in #24608
2025-07-26std.Io.Reader: add rebase to the vtableAndrew Kelley
This eliminates a footgun and special case handling with fixed buffers, as well as allowing decompression streams to keep a window in the output buffer.
2025-07-25std.compress.zstd.Decompress: fix bytes_written trackingAndrew Kelley
2025-07-25std.compress.zstd: keep frame state between blocksAndrew Kelley
2025-07-25std.compress.zstd: fix endianness issueAndrew Kelley
instead of manually bitcast, use the handy dandy takeStruct function.
2025-07-25std.compress.zstd: respect the window lengthAndrew Kelley
2025-07-25std: rework zstd for new I/O APIAndrew Kelley
This passes tests but it doesn't provide as big a window size as is required to decompress larger streams. The next commit in this branch will work towards that, without introducing an additional buffer.