Fixes: Timeout Fixes: 71135/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_EACMV_fuzzer-6251879028293632
Showing the changes to libavcodec (1 of 1 file). Show all
Unified · Split
| @@ -194,12 +194,15 @@ static int cmv_decode_frame(AVCodecContext *avctx, AVFrame *frame, · 193 unmodified lines | ||
| 194 | 194 | if ((ret = av_image_check_size(s->width, s->height, 0, s->avctx)) < 0) |
| 195 | 195 | return ret; |
| 196 | 196 | |
| 197 | + buf += EA_PREAMBLE_SIZE; | |
| 198 | + if (!(buf[0]&1) && buf_end - buf < s->width * s->height * (int64_t)(100 - s->avctx->discard_damaged_percentage) / 100) | |
| 199 | + return AVERROR_INVALIDDATA; | |
| 200 | + | |
| 197 | 201 | if ((ret = ff_get_buffer(avctx, frame, AV_GET_BUFFER_FLAG_REF)) < 0) |
| 198 | 202 | return ret; |
| 199 | 203 | |
| 200 | 204 | memcpy(frame->data[1], s->palette, AVPALETTE_SIZE); |
| 201 | 205 | |
| 202 | − buf += EA_PREAMBLE_SIZE; | |
| 203 | 206 | if ((buf[0]&1)) { // subtype |
| 204 | 207 | cmv_decode_inter(s, frame, buf+2, buf_end); |
| 205 | 208 | frame->flags &= ~AV_FRAME_FLAG_KEY; |