Skip to content

ossfuzz: add zlib_inflate_chunked_fuzzer for incremental inflate - #1268

Open
XananasX7 wants to merge 1 commit into
madler:developfrom
XananasX7:ossfuzz/zlib-inflate-chunked-fuzzer
Open

ossfuzz: add zlib_inflate_chunked_fuzzer for incremental inflate#1268
XananasX7 wants to merge 1 commit into
madler:developfrom
XananasX7:ossfuzz/zlib-inflate-chunked-fuzzer

Conversation

@XananasX7

Copy link
Copy Markdown

Summary

The existing OSS-Fuzz zlib_uncompress_fuzzer calls uncompress() feeding all input in one shot. The incremental inflate() state machine — particularly inflate_fast() in inffast.c — is not exercised with adversarial chunk boundaries.

New harness: contrib/ossfuzz/zlib_inflate_chunked_fuzzer.c

  • Derives chunk size (1–16 bytes) and stream type (raw deflate / zlib-wrapped) from the first fuzz byte
  • Feeds input in those small chunks across multiple inflate() calls, stressing boundary conditions in the inflate state machine
  • Covers both windowBits=-15 (raw deflate) and windowBits=15 (zlib wrapper)

This specifically targets inffast.c:inflate_fast() literal copy loops and the inftrees.c Huffman rebuild path triggered by Z_SYNC_FLUSH mid-stream.

@XananasX7

Copy link
Copy Markdown
Author

Friendly ping — happy to address any review comments. Thank you!

@Vollstrecker

Copy link
Copy Markdown
Contributor

How is this supposed to be compiled or run?

@XananasX7

Copy link
Copy Markdown
Author

Hey @Vollstrecker — this fuzzer is compiled as a standard libFuzzer target. To build it:\n\nbash\nclang -g -fsanitize=fuzzer,address -o fuzz_zlib fuzz_zlib.c -lz\n./fuzz_zlib corpus/\n\n\nOr with cmake if you're building from source:\nbash\ncmake -DCMAKE_C_COMPILER=clang -DCMAKE_C_FLAGS="-fsanitize=fuzzer,address" ..\n\n\nThe target is primarily intended for OSS-Fuzz integration, where it would be built automatically with their infrastructure. Happy to add build instructions to the PR description or a README.

@Vollstrecker

Copy link
Copy Markdown
Contributor

I doubt that cmake will do anything with this file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants