Browse Source

avcodec/magicyuv: Check bits left in flags&1 branch

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
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
tags/n4.1
Michael Niedermayer 7 years ago
parent
commit
7719b8ccc7
1 changed files with 4 additions and 0 deletions
  1. +4
    -0
      libavcodec/magicyuv.c

+ 4
- 0
libavcodec/magicyuv.c View File

@@ -240,6 +240,8 @@ static int magy_decode_slice10(AVCodecContext *avctx, void *tdata,


dst = (uint16_t *)p->data[i] + j * sheight * stride; dst = (uint16_t *)p->data[i] + j * sheight * stride;
if (flags & 1) { if (flags & 1) {
if (get_bits_left(&gb) < bps * width * height)
return AVERROR_INVALIDDATA;
for (k = 0; k < height; k++) { for (k = 0; k < height; k++) {
for (x = 0; x < width; x++) for (x = 0; x < width; x++)
dst[x] = get_bits(&gb, bps); 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; dst = p->data[i] + j * sheight * stride;
if (flags & 1) { if (flags & 1) {
if (get_bits_left(&gb) < 8* width * height)
return AVERROR_INVALIDDATA;
for (k = 0; k < height; k++) { for (k = 0; k < height; k++) {
for (x = 0; x < width; x++) for (x = 0; x < width; x++)
dst[x] = get_bits(&gb, 8); dst[x] = get_bits(&gb, 8);


Loading…
Cancel
Save