diff mbox series

[FFmpeg-devel,1/5] avcodec/midivid: Check vector index

Message ID 20200209191424.19041-1-michael@niedermayer.cc
State New
Headers show
Series [FFmpeg-devel,1/5] avcodec/midivid: Check vector index
Related show

Checks

Context Check Description
andriy/ffmpeg-patchwork pending
andriy/ffmpeg-patchwork success Applied patch
andriy/ffmpeg-patchwork success Configure finished
andriy/ffmpeg-patchwork success Make finished
andriy/ffmpeg-patchwork success Make fate finished

Commit Message

Michael Niedermayer Feb. 9, 2020, 7:14 p.m. UTC
Fixes: out of array read
Fixes: 20494/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MVDV_fuzzer-5681452423577600

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

Comments

Paul B Mahol Feb. 9, 2020, 7:27 p.m. UTC | #1
lgtm

On 2/9/20, Michael Niedermayer <michael@niedermayer.cc> wrote:
> Fixes: out of array read
> Fixes:
> 20494/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MVDV_fuzzer-5681452423577600
>
> Found-by: continuous fuzzing process
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/midivid.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/libavcodec/midivid.c b/libavcodec/midivid.c
> index bb5105bd57..8d4c3b369e 100644
> --- a/libavcodec/midivid.c
> +++ b/libavcodec/midivid.c
> @@ -126,6 +126,8 @@ static int decode_mvdv(MidiVidContext *s, AVCodecContext
> *avctx, AVFrame *frame)
>                  idx9bits--;
>                  idx = bytestream2_get_byte(gb) | (((idx9val >> (7 -
> idx9bits)) & 1) << 8);
>              }
> +            if (idx >= nb_vectors)
> +                return AVERROR_INVALIDDATA;
>
>              dsty[x  +frame->linesize[0]] = vec[idx * 12 + 0];
>              dsty[x+1+frame->linesize[0]] = vec[idx * 12 + 3];
> --
> 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 Feb. 9, 2020, 8:20 p.m. UTC | #2
On Sun, Feb 09, 2020 at 08:27:50PM +0100, Paul B Mahol wrote:
> lgtm

will apply

thx

[...]
diff mbox series

Patch

diff --git a/libavcodec/midivid.c b/libavcodec/midivid.c
index bb5105bd57..8d4c3b369e 100644
--- a/libavcodec/midivid.c
+++ b/libavcodec/midivid.c
@@ -126,6 +126,8 @@  static int decode_mvdv(MidiVidContext *s, AVCodecContext *avctx, AVFrame *frame)
                 idx9bits--;
                 idx = bytestream2_get_byte(gb) | (((idx9val >> (7 - idx9bits)) & 1) << 8);
             }
+            if (idx >= nb_vectors)
+                return AVERROR_INVALIDDATA;
 
             dsty[x  +frame->linesize[0]] = vec[idx * 12 + 0];
             dsty[x+1+frame->linesize[0]] = vec[idx * 12 + 3];