diff mbox

[FFmpeg-devel] avcodec/allcodecs: Provide empty codec_list in allcodecs when ossfuzz is used

Message ID 20180528014708.21976-1-michael@niedermayer.cc
State Accepted
Commit 42f40d36b74e51a7f66a3a391924f01f3da5bea1
Headers show

Commit Message

Michael Niedermayer May 28, 2018, 1:47 a.m. UTC
The last workaround is not sufficient to make oss fuzz work with the iterate API
as it did not provide a FFmpeg that external libs can be linked to.

This patch does not fully restore the pre iterate functionality. My attempts to
do this have so far failed.

The problem with this solution is that it renders the fuzzers virtual system
ffmpeg (libs) non functional. Which differs from a real system compared to the
virtual system tested by the fuzzer.
It should theoretically not matter as the system ffmpeg wouldnt be used.
But with more cases being fuzzed we likely will hit a case where a external
lib is involved and it does matter ...

Working around this may be possible with weak symbols but so far my attempts
failed

Alternatively multiple ffmpeg could be built, this becomes messy though
quickly as they need to be all linked together. That is we need a FFmpeg
that has the iterate API modified so it can work with the resources
available to ossfuzz. And at the same time we need a ffmpeg that has
its full functionality for any external libs which use ffmpeg and are
used by ffmpeg.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavcodec/allcodecs.c    | 5 ++++-
 tools/target_dec_fuzzer.c | 5 +----
 2 files changed, 5 insertions(+), 5 deletions(-)

Comments

Michael Niedermayer May 28, 2018, 9:17 p.m. UTC | #1
On Mon, May 28, 2018 at 03:47:08AM +0200, Michael Niedermayer wrote:
> The last workaround is not sufficient to make oss fuzz work with the iterate API
> as it did not provide a FFmpeg that external libs can be linked to.
> 
> This patch does not fully restore the pre iterate functionality. My attempts to
> do this have so far failed.
> 
> The problem with this solution is that it renders the fuzzers virtual system
> ffmpeg (libs) non functional. Which differs from a real system compared to the
> virtual system tested by the fuzzer.
> It should theoretically not matter as the system ffmpeg wouldnt be used.
> But with more cases being fuzzed we likely will hit a case where a external
> lib is involved and it does matter ...
> 
> Working around this may be possible with weak symbols but so far my attempts
> failed
> 
> Alternatively multiple ffmpeg could be built, this becomes messy though
> quickly as they need to be all linked together. That is we need a FFmpeg
> that has the iterate API modified so it can work with the resources
> available to ossfuzz. And at the same time we need a ffmpeg that has
> its full functionality for any external libs which use ffmpeg and are
> used by ffmpeg.
> 
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/allcodecs.c    | 5 ++++-
>  tools/target_dec_fuzzer.c | 5 +----
>  2 files changed, 5 insertions(+), 5 deletions(-)

will apply
diff mbox

Patch

diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index 7b7a8c71ff..90d170b06b 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -762,7 +762,10 @@  extern AVCodec ff_vp9_vaapi_encoder;
 
 // The iterate API is not usable with ossfuzz due to the excessive size of binaries created
 #if CONFIG_OSSFUZZ
-extern AVCodec * codec_list[];
+AVCodec * codec_list[] = {
+    NULL,
+    NULL
+};
 #else
 #include "libavcodec/codec_list.c"
 #endif
diff --git a/tools/target_dec_fuzzer.c b/tools/target_dec_fuzzer.c
index 26a4cc2e89..a0e8943c82 100644
--- a/tools/target_dec_fuzzer.c
+++ b/tools/target_dec_fuzzer.c
@@ -56,10 +56,7 @@ 
 
 int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size);
 
-AVCodec * codec_list[] = {
-    NULL,
-    NULL
-};
+extern AVCodec * codec_list[];
 
 static void error(const char *err)
 {