Commit 37826566 authored by Michael Niedermayer's avatar Michael Niedermayer

avcodec/mjpegdec: Check for for the bitstream end in mjpeg_decode_scan_progressive_ac()

Fixes timeout
Fixes: 496/clusterfuzz-testcase-5805083497332736

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/targets/ffmpegSigned-off-by: 's avatarMichael Niedermayer <michael@niedermayer.cc>
parent 8bdba109
...@@ -1397,6 +1397,10 @@ static int mjpeg_decode_scan_progressive_ac(MJpegDecodeContext *s, int ss, ...@@ -1397,6 +1397,10 @@ static int mjpeg_decode_scan_progressive_ac(MJpegDecodeContext *s, int ss,
int block_idx = mb_y * s->block_stride[c]; int block_idx = mb_y * s->block_stride[c];
int16_t (*block)[64] = &s->blocks[c][block_idx]; int16_t (*block)[64] = &s->blocks[c][block_idx];
uint8_t *last_nnz = &s->last_nnz[c][block_idx]; uint8_t *last_nnz = &s->last_nnz[c][block_idx];
if (get_bits_left(&s->gb) <= 0) {
av_log(s->avctx, AV_LOG_ERROR, "bitstream truncated in mjpeg_decode_scan_progressive_ac\n");
return AVERROR_INVALIDDATA;
}
for (mb_x = 0; mb_x < s->mb_width; mb_x++, block++, last_nnz++) { for (mb_x = 0; mb_x < s->mb_width; mb_x++, block++, last_nnz++) {
int ret; int ret;
if (s->restart_interval && !s->restart_count) if (s->restart_interval && !s->restart_count)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment