diff options
author | Michael Niedermayer <michael@niedermayer.cc> | 2020-10-10 17:25:46 +0200 |
---|---|---|
committer | Michael Niedermayer <michael@niedermayer.cc> | 2020-10-12 21:01:48 +0200 |
commit | d40679d89c44fd9decc06d12a411007e73de1bd0 (patch) | |
tree | d65480fef128e6b993cfda80c156f5dac331ad90 | |
parent | 86b485b5d68e20f8e804ee519463bce31da5417b (diff) | |
download | ffmpeg-d40679d89c44fd9decc06d12a411007e73de1bd0.tar.gz |
Add support for building fuzzer tools for an individual demuxer
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r-- | Makefile | 4 | ||||
-rw-r--r-- | tools/Makefile | 3 | ||||
-rw-r--r-- | tools/target_dem_fuzzer.c | 9 |
3 files changed, 15 insertions, 1 deletions
@@ -53,6 +53,9 @@ target_dec_%_fuzzer$(EXESUF): target_dec_%_fuzzer.o $(FF_DEP_LIBS) tools/target_bsf_%_fuzzer$(EXESUF): tools/target_bsf_%_fuzzer.o $(FF_DEP_LIBS) $(LD) $(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $^ $(ELIBS) $(FF_EXTRALIBS) $(LIBFUZZER_PATH) +target_dem_%_fuzzer$(EXESUF): target_dem_%_fuzzer.o $(FF_DEP_LIBS) + $(LD) $(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $^ $(ELIBS) $(FF_EXTRALIBS) $(LIBFUZZER_PATH) + tools/target_dem_fuzzer$(EXESUF): tools/target_dem_fuzzer.o $(FF_DEP_LIBS) $(LD) $(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $^ $(ELIBS) $(FF_EXTRALIBS) $(LIBFUZZER_PATH) @@ -63,6 +66,7 @@ tools/sofa2wavs$(EXESUF): ELIBS = $(FF_EXTRALIBS) tools/uncoded_frame$(EXESUF): $(FF_DEP_LIBS) tools/uncoded_frame$(EXESUF): ELIBS = $(FF_EXTRALIBS) tools/target_dec_%_fuzzer$(EXESUF): $(FF_DEP_LIBS) +tools/target_dem_%_fuzzer$(EXESUF): $(FF_DEP_LIBS) CONFIGURABLE_COMPONENTS = \ $(wildcard $(FFLIBS:%=$(SRC_PATH)/lib%/all*.c)) \ diff --git a/tools/Makefile b/tools/Makefile index 88d64ce6d2..48fa131eeb 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -8,6 +8,9 @@ tools/target_dec_%_fuzzer.o: tools/target_dec_fuzzer.c tools/target_bsf_%_fuzzer.o: tools/target_bsf_fuzzer.c $(COMPILE_C) -DFFMPEG_BSF=$* +tools/target_dem_%_fuzzer.o: tools/target_dem_fuzzer.c + $(COMPILE_C) -DFFMPEG_DEMUXER=$* -DIO_FLAT=0 + tools/target_dem_fuzzer.o: tools/target_dem_fuzzer.c $(COMPILE_C) -DIO_FLAT=1 diff --git a/tools/target_dem_fuzzer.c b/tools/target_dem_fuzzer.c index eefb5c5fa3..79d572a6dc 100644 --- a/tools/target_dem_fuzzer.c +++ b/tools/target_dem_fuzzer.c @@ -103,8 +103,15 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { static int c; int seekable = 0; int ret; + AVInputFormat *fmt = NULL; if (!c) { +#ifdef FFMPEG_DEMUXER +#define DEMUXER_SYMBOL0(DEMUXER) ff_##DEMUXER##_demuxer +#define DEMUXER_SYMBOL(DEMUXER) DEMUXER_SYMBOL0(DEMUXER) + extern AVInputFormat DEMUXER_SYMBOL(FFMPEG_DEMUXER); + fmt = &DEMUXER_SYMBOL(FFMPEG_DEMUXER); +#endif av_register_all(); avcodec_register_all(); av_log_set_level(AV_LOG_PANIC); @@ -166,7 +173,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { avfmt->pb = fuzzed_pb; - ret = avformat_open_input(&avfmt, filename, NULL, NULL); + ret = avformat_open_input(&avfmt, filename, fmt, NULL); if (ret < 0) { av_freep(&fuzzed_pb->buffer); av_freep(&fuzzed_pb); |