diff mbox

[FFmpeg-devel,1/3] avcodec/magicyuv: Check bits left in flags&1 branch

Message ID 20180624024623.26645-1-michael@niedermayer.cc
State Accepted
Commit 7719b8ccc790b6e1325af0afe2b65e2334a7173c
Headers show

Commit Message

Michael Niedermayer June 24, 2018, 2:46 a.m. UTC
Fixes: Timeout
Fixes: 8690/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MAGICYUV_fuzzer-6542020913922048

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

Comments

Paul B Mahol June 24, 2018, 8:20 a.m. UTC | #1
On 6/24/18, Michael Niedermayer <michael@niedermayer.cc> wrote:
> Fixes: Timeout
> Fixes:
> 8690/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MAGICYUV_fuzzer-6542020913922048
>
> Found-by: continuous fuzzing process
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/magicyuv.c | 4 ++++
>  1 file changed, 4 insertions(+)
>

lgtm
Michael Niedermayer June 25, 2018, 12:09 a.m. UTC | #2
On Sun, Jun 24, 2018 at 10:20:23AM +0200, Paul B Mahol wrote:
> On 6/24/18, Michael Niedermayer <michael@niedermayer.cc> wrote:
> > Fixes: Timeout
> > Fixes:
> > 8690/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MAGICYUV_fuzzer-6542020913922048
> >
> > Found-by: continuous fuzzing process
> > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> > Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> > ---
> >  libavcodec/magicyuv.c | 4 ++++
> >  1 file changed, 4 insertions(+)
> >
> 
> lgtm

will apply

thanks

[...]
diff mbox

Patch

diff --git a/libavcodec/magicyuv.c b/libavcodec/magicyuv.c
index 9c6e1ba1b1..1a129c2619 100644
--- a/libavcodec/magicyuv.c
+++ b/libavcodec/magicyuv.c
@@ -240,6 +240,8 @@  static int magy_decode_slice10(AVCodecContext *avctx, void *tdata,
 
         dst = (uint16_t *)p->data[i] + j * sheight * stride;
         if (flags & 1) {
+            if (get_bits_left(&gb) < bps * width * height)
+                return AVERROR_INVALIDDATA;
             for (k = 0; k < height; k++) {
                 for (x = 0; x < width; x++)
                     dst[x] = get_bits(&gb, bps);
@@ -368,6 +370,8 @@  static int magy_decode_slice(AVCodecContext *avctx, void *tdata,
 
         dst = p->data[i] + j * sheight * stride;
         if (flags & 1) {
+            if (get_bits_left(&gb) < 8* width * height)
+                return AVERROR_INVALIDDATA;
             for (k = 0; k < height; k++) {
                 for (x = 0; x < width; x++)
                     dst[x] = get_bits(&gb, 8);