[FFmpeg-devel] avcodec/hevcdec: Avoid only partly skiping duplicate first slices

Submitted by Michael Niedermayer on March 23, 2019, 8:25 p.m.

Details

Message ID 20190323202503.6182-1-michael@niedermayer.cc
State New
Headers show

Commit Message

Michael Niedermayer March 23, 2019, 8:25 p.m.
Fixes: NULL pointer dereference and out of array access
Fixes: 13871/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HEVC_fuzzer-5746167087890432
Fixes: 13845/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HEVC_fuzzer-5650370728034304

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

Comments

James Almer March 23, 2019, 8:33 p.m.
On 3/23/2019 5:25 PM, Michael Niedermayer wrote:
> Fixes: NULL pointer dereference and out of array access
> Fixes: 13871/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HEVC_fuzzer-5746167087890432
> Fixes: 13845/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HEVC_fuzzer-5650370728034304
> 
> Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/hevcdec.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
> index 86adab0ae1..4d149f4d9f 100644
> --- a/libavcodec/hevcdec.c
> +++ b/libavcodec/hevcdec.c
> @@ -488,6 +488,9 @@ static int hls_slice_header(HEVCContext *s)
>  
>      // Coded parameters
>      sh->first_slice_in_pic_flag = get_bits1(gb);
> +    if (s->ref && sh->first_slice_in_pic_flag)
> +        return 0; // This slice will be skiped later, do not corrupt state

I assume this is a regression after 70c8c8a818? If so, please also
backport this patch to branches 2.8 to 4.1.

> +
>      if ((IS_IDR(s) || IS_BLA(s)) && sh->first_slice_in_pic_flag) {
>          s->seq_decode = (s->seq_decode + 1) & 0xff;
>          s->max_ra     = INT_MAX;
>
Michael Niedermayer March 24, 2019, 9:42 a.m.
On Sat, Mar 23, 2019 at 05:33:25PM -0300, James Almer wrote:
> On 3/23/2019 5:25 PM, Michael Niedermayer wrote:
> > Fixes: NULL pointer dereference and out of array access
> > Fixes: 13871/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HEVC_fuzzer-5746167087890432
> > Fixes: 13845/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HEVC_fuzzer-5650370728034304
> > 
> > Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> > Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> > ---
> >  libavcodec/hevcdec.c | 3 +++
> >  1 file changed, 3 insertions(+)
> > 
> > diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
> > index 86adab0ae1..4d149f4d9f 100644
> > --- a/libavcodec/hevcdec.c
> > +++ b/libavcodec/hevcdec.c
> > @@ -488,6 +488,9 @@ static int hls_slice_header(HEVCContext *s)
> >  
> >      // Coded parameters
> >      sh->first_slice_in_pic_flag = get_bits1(gb);
> > +    if (s->ref && sh->first_slice_in_pic_flag)
> > +        return 0; // This slice will be skiped later, do not corrupt state
> 
> I assume this is a regression after 70c8c8a818? If so, please also
> backport this patch to branches 2.8 to 4.1.

yes, will do

[...]

Patch hide | download patch | download mbox

diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
index 86adab0ae1..4d149f4d9f 100644
--- a/libavcodec/hevcdec.c
+++ b/libavcodec/hevcdec.c
@@ -488,6 +488,9 @@  static int hls_slice_header(HEVCContext *s)
 
     // Coded parameters
     sh->first_slice_in_pic_flag = get_bits1(gb);
+    if (s->ref && sh->first_slice_in_pic_flag)
+        return 0; // This slice will be skiped later, do not corrupt state
+
     if ((IS_IDR(s) || IS_BLA(s)) && sh->first_slice_in_pic_flag) {
         s->seq_decode = (s->seq_decode + 1) & 0xff;
         s->max_ra     = INT_MAX;