[FFmpeg-devel] [PATCH] avcodec/amr_parser: passthrough if channels is unknown

Michael Niedermayer michael at niedermayer.cc
Thu Oct 7 17:12:26 EEST 2021


On Tue, Oct 05, 2021 at 11:08:19PM +0200, Paul B Mahol wrote:
> On Tue, Oct 5, 2021 at 11:03 PM James Almer <jamrial at gmail.com> wrote:
> 
> > On 10/5/2021 5:51 PM, Michael Niedermayer wrote:
> > > Fixes: division by 0
> > > Fixes:
> > 39562/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AMRWB_fuzzer-5448834960982016
> > > Fixes:
> > 39589/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AMRWB_fuzzer-6119205334810624
> > >
> > > Found-by: continuous fuzzing process
> > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> > > Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
> > > ---
> > >   libavcodec/amr_parser.c | 2 +-
> > >   1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > diff --git a/libavcodec/amr_parser.c b/libavcodec/amr_parser.c
> > > index 79258d4d0cf..9fb7711fee0 100644
> > > --- a/libavcodec/amr_parser.c
> > > +++ b/libavcodec/amr_parser.c
> > > @@ -62,7 +62,7 @@ static int amr_parse(AVCodecParserContext *s1,
> > >       *poutbuf_size = 0;
> > >       *poutbuf = NULL;
> > >
> > > -    if (s1->flags & PARSER_FLAG_COMPLETE_FRAMES) {
> > > +    if (s1->flags & PARSER_FLAG_COMPLETE_FRAMES || !avctx->channels) {
> >
> > No line in the parser divides by avctx->channels. There's however one
> > doing a modulo avctx->channels. Wouldn't this mean the compiler is being
> > overzealous with optimizations?
> >
> > Also, instead of this please do the same as the decoder, and set
> > channels to 1 and layout to mono if nothing is already set. Forcing the
> > "complete frames" path when no channels are set feels like a hacky
> > workaround.
> > If the relevant parser flag is not set, then you must not treat packets
> > as if they contained complete frames.
> >
> 
> Agreed also with that solution.

will apply that then

thx

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Republics decline into democracies and democracies degenerate into
despotisms. -- Aristotle
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20211007/f19b4cf5/attachment.sig>


More information about the ffmpeg-devel mailing list