diff mbox

[FFmpeg-devel] tools/target_dec_fuzzer: set request_channel_layout

Message ID 20191206230847.GP3089@michaelspb
State New
Headers show

Commit Message

Michael Niedermayer Dec. 6, 2019, 11:08 p.m. UTC
On Fri, Dec 06, 2019 at 11:56:13AM -0300, James Almer wrote:
> Should increase coverage of some decoders.
> 
> Signed-off-by: James Almer <jamrial@gmail.com>
> ---
> Passing 6 to av_get_default_channel_layout() will return the 5.1 layout but
> never 5.1(side), which is for example what the dts decoder actually looks for.
> Any suggestion on how to make the fuzzer pick one of the non default layouts
> using a given amount of channels?

did you try:




> 
>  tools/target_dec_fuzzer.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/tools/target_dec_fuzzer.c b/tools/target_dec_fuzzer.c
> index dcf47b0f4d..fbfbbbc7ac 100644
> --- a/tools/target_dec_fuzzer.c
> +++ b/tools/target_dec_fuzzer.c
> @@ -47,6 +47,7 @@
>  
>  #include "config.h"
>  #include "libavutil/avassert.h"
> +#include "libavutil/channel_layout.h"
>  #include "libavutil/imgutils.h"
>  #include "libavutil/intreadwrite.h"
>  
> @@ -207,6 +208,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
>  
>          ctx->sample_rate                        = bytestream2_get_le32(&gbc);
>          ctx->channels                           = (unsigned)bytestream2_get_le32(&gbc) % FF_SANE_NB_CHANNELS;
> +        ctx->request_channel_layout             = av_get_default_channel_layout((unsigned)bytestream2_get_le32(&gbc) % FF_SANE_NB_CHANNELS);
>          ctx->block_align                        = bytestream2_get_le32(&gbc);
>          ctx->codec_tag                          = bytestream2_get_le32(&gbc);
>          keyframes                               = bytestream2_get_le64(&gbc);


Its better to add reading at the end so as to minimize disruption to existing
testcases

Thanks

[...]

Comments

James Almer Dec. 6, 2019, 11:31 p.m. UTC | #1
On 12/6/2019 8:08 PM, Michael Niedermayer wrote:
> On Fri, Dec 06, 2019 at 11:56:13AM -0300, James Almer wrote:
>> Should increase coverage of some decoders.
>>
>> Signed-off-by: James Almer <jamrial@gmail.com>
>> ---
>> Passing 6 to av_get_default_channel_layout() will return the 5.1 layout but
>> never 5.1(side), which is for example what the dts decoder actually looks for.
>> Any suggestion on how to make the fuzzer pick one of the non default layouts
>> using a given amount of channels?
> 
> did you try:
> 
> diff --git a/tools/target_dec_fuzzer.c b/tools/target_dec_fuzzer.c
> index 691a79329f..d53dccdcf5 100644
> --- a/tools/target_dec_fuzzer.c
> +++ b/tools/target_dec_fuzzer.c
> @@ -212,6 +212,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
>          ctx->codec_tag                          = bytestream2_get_le32(&gbc);
>          keyframes                               = bytestream2_get_le64(&gbc);
>          flushpattern                            = bytestream2_get_le64(&gbc);
> +        ctx->request_channel_layout             = bytestream2_get_le64(&gbc);

I guess it'll going to get a hit at some point whereas my approach will
not, so LGTM.

>  
>          if (extradata_size < size) {
>              ctx->extradata = av_mallocz(extradata_size + AV_INPUT_BUFFER_PADDING_SIZE);
> 
> 
> 
>>
>>  tools/target_dec_fuzzer.c | 2 ++
>>  1 file changed, 2 insertions(+)
>>
>> diff --git a/tools/target_dec_fuzzer.c b/tools/target_dec_fuzzer.c
>> index dcf47b0f4d..fbfbbbc7ac 100644
>> --- a/tools/target_dec_fuzzer.c
>> +++ b/tools/target_dec_fuzzer.c
>> @@ -47,6 +47,7 @@
>>  
>>  #include "config.h"
>>  #include "libavutil/avassert.h"
>> +#include "libavutil/channel_layout.h"
>>  #include "libavutil/imgutils.h"
>>  #include "libavutil/intreadwrite.h"
>>  
>> @@ -207,6 +208,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
>>  
>>          ctx->sample_rate                        = bytestream2_get_le32(&gbc);
>>          ctx->channels                           = (unsigned)bytestream2_get_le32(&gbc) % FF_SANE_NB_CHANNELS;
>> +        ctx->request_channel_layout             = av_get_default_channel_layout((unsigned)bytestream2_get_le32(&gbc) % FF_SANE_NB_CHANNELS);
>>          ctx->block_align                        = bytestream2_get_le32(&gbc);
>>          ctx->codec_tag                          = bytestream2_get_le32(&gbc);
>>          keyframes                               = bytestream2_get_le64(&gbc);
> 
> 
> Its better to add reading at the end so as to minimize disruption to existing
> testcases
> 
> Thanks
> 
> [...]
> 
> 
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>
Michael Niedermayer Dec. 7, 2019, 7:25 p.m. UTC | #2
On Fri, Dec 06, 2019 at 08:31:09PM -0300, James Almer wrote:
> On 12/6/2019 8:08 PM, Michael Niedermayer wrote:
> > On Fri, Dec 06, 2019 at 11:56:13AM -0300, James Almer wrote:
> >> Should increase coverage of some decoders.
> >>
> >> Signed-off-by: James Almer <jamrial@gmail.com>
> >> ---
> >> Passing 6 to av_get_default_channel_layout() will return the 5.1 layout but
> >> never 5.1(side), which is for example what the dts decoder actually looks for.
> >> Any suggestion on how to make the fuzzer pick one of the non default layouts
> >> using a given amount of channels?
> > 
> > did you try:
> > 
> > diff --git a/tools/target_dec_fuzzer.c b/tools/target_dec_fuzzer.c
> > index 691a79329f..d53dccdcf5 100644
> > --- a/tools/target_dec_fuzzer.c
> > +++ b/tools/target_dec_fuzzer.c
> > @@ -212,6 +212,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
> >          ctx->codec_tag                          = bytestream2_get_le32(&gbc);
> >          keyframes                               = bytestream2_get_le64(&gbc);
> >          flushpattern                            = bytestream2_get_le64(&gbc);
> > +        ctx->request_channel_layout             = bytestream2_get_le64(&gbc);
> 
> I guess it'll going to get a hit at some point whereas my approach will
> not, so LGTM.

will apply (unless i see some problem before)

thanks

[...]
diff mbox

Patch

diff --git a/tools/target_dec_fuzzer.c b/tools/target_dec_fuzzer.c
index 691a79329f..d53dccdcf5 100644
--- a/tools/target_dec_fuzzer.c
+++ b/tools/target_dec_fuzzer.c
@@ -212,6 +212,7 @@  int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
         ctx->codec_tag                          = bytestream2_get_le32(&gbc);
         keyframes                               = bytestream2_get_le64(&gbc);
         flushpattern                            = bytestream2_get_le64(&gbc);
+        ctx->request_channel_layout             = bytestream2_get_le64(&gbc);
 
         if (extradata_size < size) {
             ctx->extradata = av_mallocz(extradata_size + AV_INPUT_BUFFER_PADDING_SIZE);