From c9bb73e3bf96c260ea188b9e408486bfeb977d4d Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 27 Oct 2026 17:27:38 +0000 Subject: [PATCH] fuzz/c/std: enlarge the brotli fuzzer's encoder dst; clarify brcat's parity claim Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01UZ978Fjdsyig4v3wYAZRg5 --- example/brcat/brcat.c | 11 +++++++---- fuzz/c/std/brotli_fuzzer.c | 5 ++++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/example/brcat/brcat.c b/example/brcat/brcat.c index 80d4bba3..c6b71b97 100644 --- a/example/brcat/brcat.c +++ b/example/brcat/brcat.c @@ -22,10 +22,13 @@ Flags: -quality=N the encoder's quality, 0 to 11. The default is 11. -fail-if-unsandboxed exit with an error if the seccomp sandbox failed. -The encoder's output is byte-for-byte identical to the brotli reference -implementation's (libbrotlienc v1.2.1) with the same quality, lgwin and large -window parameters, on every platform. Like that reference implementation, -qualities 10 and 11 are much slower than lower qualities. +The encoder's output is byte-for-byte identical, on every platform, to what +the brotli reference implementation's library (libbrotlienc v1.2.1) produces +for the same parameters and the same sequence of calls. That output depends +on how the input is split into calls (for example, the first call's length is +the default size hint), so it can differ from the "brotli" command line tool's, +which reads 512 KiB at a time and sets a size hint. Like that reference +implementation, qualities 10 and 11 are much slower than lower qualities. To run: diff --git a/fuzz/c/std/brotli_fuzzer.c b/fuzz/c/std/brotli_fuzzer.c index d613e7ee..71a6bd3e 100644 --- a/fuzz/c/std/brotli_fuzzer.c +++ b/fuzz/c/std/brotli_fuzzer.c @@ -132,7 +132,10 @@ static const uint8_t g_serialized_dictionary[] = { // at qualities 10 and 11, which are slow. #define ENC_MAX_INPUT 65536 #define ENC_MAX_INPUT_HQ 4096 -#define ENC_DST_ARRAY_SIZE (2 * ENC_MAX_INPUT + 65536) +// With 1-byte chunks and frequent flushes, each input byte can become its own +// metablock plus a padding block (about 4 bytes per input byte at qualities 0 +// and 1), so the dst buffer is sized well above that. +#define ENC_DST_ARRAY_SIZE (8 * ENC_MAX_INPUT + 65536) static wuffs_brotli__encoder g_encoder; static wuffs_brotli__decoder g_rt_decoder;