1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-11-21 10:55:51 +02:00

Add support for building fuzzer tools for an individual demuxer

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
Michael Niedermayer 2020-10-10 17:25:46 +02:00
parent 86b485b5d6
commit d40679d89c
3 changed files with 15 additions and 1 deletions

View File

@ -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)) \

View File

@ -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

View File

@ -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);