[FFmpeg-devel,2/2] tools/target_dec_fuzzer: fuzz channels and sample_rate too

Submitted by Michael Niedermayer on Sept. 20, 2019, 9:09 a.m.

Details

Message ID 20190920090949.31497-2-michael@niedermayer.cc
State Accepted
Commit 87a7fc692d8bff99879dc4a27d89e70272b5a79f
Headers show

Commit Message

Michael Niedermayer Sept. 20, 2019, 9:09 a.m.
This should increase coverage over more audio decoders.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 tools/target_dec_fuzzer.c | 7 +++++++
 1 file changed, 7 insertions(+)

Patch hide | download patch | download mbox

diff --git a/tools/target_dec_fuzzer.c b/tools/target_dec_fuzzer.c
index 8b1ad1f8da..b131a5f2b6 100644
--- a/tools/target_dec_fuzzer.c
+++ b/tools/target_dec_fuzzer.c
@@ -54,6 +54,9 @@ 
 #include "libavcodec/bytestream.h"
 #include "libavformat/avformat.h"
 
+//For FF_SANE_NB_CHANNELS, so we dont waste energy testing things that will get instantly rejected
+#include "libavcodec/internal.h"
+
 int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size);
 
 extern AVCodec * codec_list[];
@@ -170,6 +173,10 @@  int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
             parser = av_parser_init(c->id);
 
         extradata_size = bytestream2_get_le32(&gbc);
+
+        ctx->sample_rate                        = bytestream2_get_le32(&gbc);
+        ctx->channels                           = (unsigned)bytestream2_get_le32(&gbc) % FF_SANE_NB_CHANNELS;
+
         if (extradata_size < size) {
             ctx->extradata = av_mallocz(extradata_size + AV_INPUT_BUFFER_PADDING_SIZE);
             if (ctx->extradata) {