avcodec/mjpegdec: Check escape sequence validity

Fixes assertion failure
Fixes: asan_heap-oob_1c1a4ea_1242_cov_2274415971_TESTcmyk.jpg

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Michael Niedermayer 2015-02-04 20:13:18 +01:00
parent a6ba4c1116
commit b844584c10
1 changed files with 4 additions and 0 deletions

View File

@ -1779,6 +1779,10 @@ int ff_mjpeg_find_marker(MJpegDecodeContext *s,
put_bits(&pb, 8, x);
if (x == 0xFF) {
x = src[b++];
if (x & 0x80) {
av_log(s->avctx, AV_LOG_WARNING, "Invalid escape sequence\n");
x &= 0x7f;
}
put_bits(&pb, 7, x);
bit_count--;
}