diff mbox series

[FFmpeg-devel,2/2] avcodec/huffyuvdec: Test vertical coordinate more often

Message ID 20200605204159.23848-2-michael@niedermayer.cc
State Accepted
Commit a1223ddc5692772198a02600ecff2545f32b37be
Headers show
Series [FFmpeg-devel,1/2] avcodec/movtextdec: Fix shift overflows in mov_text_init() | expand

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Michael Niedermayer June 5, 2020, 8:41 p.m. UTC
Fixes: out of array access
Fixes: 22892/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HYMT_fuzzer-5135996772679680.fuzz

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

Comments

Paul B Mahol June 5, 2020, 9:18 p.m. UTC | #1
probably ok

On 6/5/20, Michael Niedermayer <michael@niedermayer.cc> wrote:
> Fixes: out of array access
> Fixes:
> 22892/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HYMT_fuzzer-5135996772679680.fuzz
>
> Found-by: continuous fuzzing process
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/huffyuvdec.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
>
> diff --git a/libavcodec/huffyuvdec.c b/libavcodec/huffyuvdec.c
> index 0ee7ec3917..e713b91e4d 100644
> --- a/libavcodec/huffyuvdec.c
> +++ b/libavcodec/huffyuvdec.c
> @@ -928,12 +928,16 @@ static int decode_slice(AVCodecContext *avctx, AVFrame
> *p, int height,
>                  left= left_prediction(s, p->data[plane], s->temp[0], w, 0);
>
>                  y = 1;
> +                if (y >= h)
> +                    break;
>
>                  /* second line is left predicted for interlaced case */
>                  if (s->interlaced) {
>                      decode_plane_bitstream(s, w, plane);
>                      left = left_prediction(s, p->data[plane] +
> p->linesize[plane], s->temp[0], w, left);
>                      y++;
> +                    if (y >= h)
> +                        break;
>                  }
>
>                  lefttop = p->data[plane][0];
> @@ -1045,6 +1049,8 @@ static int decode_slice(AVCodecContext *avctx, AVFrame
> *p, int height,
>                  }
>
>                  cy = y = 1;
> +                if (y >= height)
> +                    break;
>
>                  /* second line is left predicted for interlaced case */
>                  if (s->interlaced) {
> @@ -1057,6 +1063,8 @@ static int decode_slice(AVCodecContext *avctx, AVFrame
> *p, int height,
>                      }
>                      y++;
>                      cy++;
> +                    if (y >= height)
> +                        break;
>                  }
>
>                  /* next 4 pixels are left predicted too */
> --
> 2.17.1
>
> _______________________________________________
> 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 June 5, 2020, 10:39 p.m. UTC | #2
On Fri, Jun 05, 2020 at 11:18:25PM +0200, Paul B Mahol wrote:
> probably ok

will apply

thx

[...]
diff mbox series

Patch

diff --git a/libavcodec/huffyuvdec.c b/libavcodec/huffyuvdec.c
index 0ee7ec3917..e713b91e4d 100644
--- a/libavcodec/huffyuvdec.c
+++ b/libavcodec/huffyuvdec.c
@@ -928,12 +928,16 @@  static int decode_slice(AVCodecContext *avctx, AVFrame *p, int height,
                 left= left_prediction(s, p->data[plane], s->temp[0], w, 0);
 
                 y = 1;
+                if (y >= h)
+                    break;
 
                 /* second line is left predicted for interlaced case */
                 if (s->interlaced) {
                     decode_plane_bitstream(s, w, plane);
                     left = left_prediction(s, p->data[plane] + p->linesize[plane], s->temp[0], w, left);
                     y++;
+                    if (y >= h)
+                        break;
                 }
 
                 lefttop = p->data[plane][0];
@@ -1045,6 +1049,8 @@  static int decode_slice(AVCodecContext *avctx, AVFrame *p, int height,
                 }
 
                 cy = y = 1;
+                if (y >= height)
+                    break;
 
                 /* second line is left predicted for interlaced case */
                 if (s->interlaced) {
@@ -1057,6 +1063,8 @@  static int decode_slice(AVCodecContext *avctx, AVFrame *p, int height,
                     }
                     y++;
                     cy++;
+                    if (y >= height)
+                        break;
                 }
 
                 /* next 4 pixels are left predicted too */