Add OSS-Fuzz compatible libFuzzer targets for high-level API#137
Open
s2ongmo wants to merge 1 commit intolieff:masterfrom
Open
Add OSS-Fuzz compatible libFuzzer targets for high-level API#137s2ongmo wants to merge 1 commit intolieff:masterfrom
s2ongmo wants to merge 1 commit intolieff:masterfrom
Conversation
Author
|
Thanks for merging #139 — the fix looks solid. These fuzz targets (fuzz_decode_frame, fuzz_decode_buf, fuzz_decode_ex) were what originally caught that seek truncation bug. Would you be open to merging this PR so the fuzz directory can be used for continuous fuzzing via OSS-Fuzz? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add OSS-Fuzz compatible fuzz targets for high-level API
Summary
This PR modernizes the existing fuzzing infrastructure and adds three libFuzzer-compatible fuzz targets covering the core decode, buffer load/iterate, and streaming/seek APIs. The goal is to integrate minimp3 into Google's OSS-Fuzz for continuous fuzzing.
Background
The existing
fuzzing/fuzz.cis an AFL-only harness (stdin +__AFL_LOOP). TheLIBFUZZERpath inminimp3_test.cdoes not compile (calls 4-parameterdecode_filewith 6 arguments). This PR adds standalone libFuzzer targets that work with OSS-Fuzz's build system while keeping the existing AFL harness intact.What's Added
fuzz/fuzz_decode_frame.c— Core frame decodermp3dec_decode_frame()in a loop over the input bufferminimp3.h(Layer 1/2/3 decode, sync, ID3 skip)fuzz/fuzz_decode_buf.c— Buffer decode + iterationmp3dec_load_buf()andmp3dec_iterate_buf()minimp3_ex.hhigh-level full-buffer APIsfuzz/fuzz_decode_ex.c— Streaming API with seekmp3dec_ex_open_buf(),mp3dec_ex_read(),mp3dec_ex_seek()minimp3_ex.hfuzz/mp3.dict— MP3 format dictionary (frame sync words, ID3/APE/Xing tokens)Build
# Example: ASAN + libFuzzer clang -g -O1 -fsanitize=address -I. -c fuzz/fuzz_decode_frame.c -o fuzz_decode_frame.o clang++ -g -O1 -fsanitize=address,fuzzer fuzz_decode_frame.o -o fuzz_decode_frame -lmAll three targets build cleanly with ASAN, UBSAN, and MSAN.
Notes
fuzzing/directory andminimp3_test.care untouched.