[FFmpeg-devel,2/2] avcodec/vp3: Check that theora is theora

Submitted by Michael Niedermayer on July 21, 2019, 11:25 p.m.

Details

Message ID 20190721232528.8923-2-michael@niedermayer.cc
State New
Headers show

Commit Message

Michael Niedermayer July 21, 2019, 11:25 p.m.
Fixes: Timeout (2min -> 100ms)
Fixes: 15366/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_THEORA_fuzzer-5737849938247680

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavcodec/vp3.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Reimar Döffinger July 22, 2019, 5:07 a.m.
On 22.07.2019, at 01:25, Michael Niedermayer <michael@niedermayer.cc> wrote:

> Fixes: Timeout (2min -> 100ms)
> Fixes: 15366/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_THEORA_fuzzer-5737849938247680
> 
> Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
> libavcodec/vp3.c | 2 ++
> 1 file changed, 2 insertions(+)
> 
> diff --git a/libavcodec/vp3.c b/libavcodec/vp3.c
> index a6f759ebf5..8a165c1275 100644
> --- a/libavcodec/vp3.c
> +++ b/libavcodec/vp3.c
> @@ -2957,6 +2957,8 @@ static int theora_decode_header(AVCodecContext *avctx, GetBitContext *gb)
>     s->theora_header = 0;
>     s->theora = get_bits_long(gb, 24);
>     av_log(avctx, AV_LOG_DEBUG, "Theora bitstream version %X\n", s->theora);
> +    if (!s->theora)
> +        return AVERROR_INVALIDDATA;

That seems rather strict, a 1-bit error in this field and we don't even try?
Maybe set to 1 instead with a request for sample?
Michael Niedermayer July 24, 2019, 12:37 p.m.
On Mon, Jul 22, 2019 at 07:07:57AM +0200, Reimar Döffinger wrote:
> 
> 
> On 22.07.2019, at 01:25, Michael Niedermayer <michael@niedermayer.cc> wrote:
> 
> > Fixes: Timeout (2min -> 100ms)
> > Fixes: 15366/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_THEORA_fuzzer-5737849938247680
> > 
> > Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> > Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> > ---
> > libavcodec/vp3.c | 2 ++
> > 1 file changed, 2 insertions(+)
> > 
> > diff --git a/libavcodec/vp3.c b/libavcodec/vp3.c
> > index a6f759ebf5..8a165c1275 100644
> > --- a/libavcodec/vp3.c
> > +++ b/libavcodec/vp3.c
> > @@ -2957,6 +2957,8 @@ static int theora_decode_header(AVCodecContext *avctx, GetBitContext *gb)
> >     s->theora_header = 0;
> >     s->theora = get_bits_long(gb, 24);
> >     av_log(avctx, AV_LOG_DEBUG, "Theora bitstream version %X\n", s->theora);
> > +    if (!s->theora)
> > +        return AVERROR_INVALIDDATA;
> 
> That seems rather strict, a 1-bit error in this field and we don't even try?
> Maybe set to 1 instead with a request for sample?

ok, will post a new patch

[...]
Reimar Döffinger July 25, 2019, 11:29 p.m.
On 24.07.2019, at 14:37, Michael Niedermayer <michael@niedermayer.cc> wrote:

> On Mon, Jul 22, 2019 at 07:07:57AM +0200, Reimar Döffinger wrote:
>> 
>> 
>> On 22.07.2019, at 01:25, Michael Niedermayer <michael@niedermayer.cc> wrote:
>> 
>>> Fixes: Timeout (2min -> 100ms)
>>> Fixes: 15366/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_THEORA_fuzzer-5737849938247680
>>> 
>>> Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
>>> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
>>> ---
>>> libavcodec/vp3.c | 2 ++
>>> 1 file changed, 2 insertions(+)
>>> 
>>> diff --git a/libavcodec/vp3.c b/libavcodec/vp3.c
>>> index a6f759ebf5..8a165c1275 100644
>>> --- a/libavcodec/vp3.c
>>> +++ b/libavcodec/vp3.c
>>> @@ -2957,6 +2957,8 @@ static int theora_decode_header(AVCodecContext *avctx, GetBitContext *gb)
>>>    s->theora_header = 0;
>>>    s->theora = get_bits_long(gb, 24);
>>>    av_log(avctx, AV_LOG_DEBUG, "Theora bitstream version %X\n", s->theora);
>>> +    if (!s->theora)
>>> +        return AVERROR_INVALIDDATA;
>> 
>> That seems rather strict, a 1-bit error in this field and we don't even try?
>> Maybe set to 1 instead with a request for sample?
> 
> ok, will post a new patch

Thanks. Sorry if it was maybe a bit nitpicky comment, but seemed like doing it a but nicer might be worth the effort.

Patch hide | download patch | download mbox

diff --git a/libavcodec/vp3.c b/libavcodec/vp3.c
index a6f759ebf5..8a165c1275 100644
--- a/libavcodec/vp3.c
+++ b/libavcodec/vp3.c
@@ -2957,6 +2957,8 @@  static int theora_decode_header(AVCodecContext *avctx, GetBitContext *gb)
     s->theora_header = 0;
     s->theora = get_bits_long(gb, 24);
     av_log(avctx, AV_LOG_DEBUG, "Theora bitstream version %X\n", s->theora);
+    if (!s->theora)
+        return AVERROR_INVALIDDATA;
 
     /* 3.2.0 aka alpha3 has the same frame orientation as original vp3
      * but previous versions have the image flipped relative to vp3 */