[FFmpeg-cvslog] Add support for building fuzzer tools for an individual demuxer

Michael Niedermayer git at videolan.org
Mon Oct 12 22:02:45 EEST 2020


ffmpeg | branch: master | Michael Niedermayer <michael at niedermayer.cc> | Sat Oct 10 17:25:46 2020 +0200| [d40679d89c44fd9decc06d12a411007e73de1bd0] | committer: Michael Niedermayer

Add support for building fuzzer tools for an individual demuxer

Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d40679d89c44fd9decc06d12a411007e73de1bd0
---

 Makefile                  | 4 ++++
 tools/Makefile            | 3 +++
 tools/target_dem_fuzzer.c | 9 ++++++++-
 3 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index 6a0dabfc5a..c8b548d126 100644
--- a/Makefile
+++ b/Makefile
@@ -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);



More information about the ffmpeg-cvslog mailing list