Fuzz NewManifestFromReader and cap the zstd decoder (closes #65)
check / check (push) Successful in 1m35s

FuzzNewManifestFromReader fails when the parser returns both or neither
of a manifest and an error, or allocates more than sixteen times its
input and the decompressed data it may read, plus room for the decoder's
window buffers. make test runs the seed corpus; make fuzz fuzzes for one
minute.

Parser bug: MaxDecompressedSize did not bound decompression. The zstd
decoder decoded a payload under 128 KiB in full before the LimitReader
read any of it. It now decodes synchronously, only what the LimitReader
reads, and refuses windows over the 8 MiB mfer writes with, since each
frame asking for a larger window gets a new buffer. Seeds: a frame
claiming 8 GiB, two frames together over the limit, empty frames with
growing windows.

Model: opus-5-5
This commit is contained in:
2026-10-04 01:36:30 +00:00
parent 1adad7d3bc
commit 00803243de
24 changed files with 182 additions and 3 deletions
Executable
+17
View File
@@ -0,0 +1,17 @@
#!/bin/sh
# script/fuzz: fuzz the manifest parser for one minute. Run by hand only:
# script/test already runs the committed seed corpus as ordinary tests,
# and CI never fuzzes. An input that fails is written to
# mfer/testdata/fuzz/FuzzNewManifestFromReader/; once the parser is fixed,
# commit it there as a regression seed.
set -eu
ROOT="$(cd "$(dirname "$0")/.." && pwd -P)"
main() {
cd "$ROOT"
go test -run '^$' -fuzz '^FuzzNewManifestFromReader$' \
-fuzztime 1m -parallel 2 ./mfer
}
main "$@"