Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion programs/fileio_asyncio.c
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,8 @@ size_t AIO_ReadPool_fillBuffer(ReadPoolCtx_t* ctx, size_t n) {
* and coalesce the remaining bytes with the next job's buffer */
if (ctx->srcBufferLoaded > 0) {
useCoalesce = 1;
memcpy(ctx->coalesceBuffer, ctx->srcBuffer, ctx->srcBufferLoaded);
/* Remaining bytes may already be in coalesceBuffer. */
memmove(ctx->coalesceBuffer, ctx->srcBuffer, ctx->srcBufferLoaded);
ctx->srcBuffer = ctx->coalesceBuffer;
}

Expand Down
17 changes: 17 additions & 0 deletions tests/cli-tests/decompression/skippable-overlap.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/sh

set -eu

# An 8-byte empty skippable frame followed by a 9-byte empty zstd frame.
# The initial 18-byte header refill moves this 17-byte stream into the
# coalesce buffer. After consuming the skippable frame, the next refill
# moves 9 bytes from offset 8 back to offset 0. Run under ASan to detect
# an overlapping memcpy.
printf '\120\052\115\030\000\000\000\000\050\265\057\375\040\000\001\000\000' > skippable-overlap.zst

# This is a valid stream and must decode successfully to empty output.
for io in --asyncio --no-asyncio; do
for operation in -t -dc; do
zstd -q "$io" "$operation" skippable-overlap.zst
done
done
Empty file.
Empty file.
Loading