1
mirror of https://git.videolan.org/git/ffmpeg.git synced 2024-10-15 12:44:47 +02:00

avcodec/mjpegdec: sanity check bits

Fixes undefined shift
Fixes: asan_heap-oob_16668e9_2_asan_heap-oob_16668e9_346_miss_congeniality_pegasus_mjpg.avi

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Michael Niedermayer 2014-10-12 00:25:47 +02:00
parent 903156aa8a
commit 0db1f2c2c7

View File

@ -256,6 +256,11 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
s->avctx->bits_per_raw_sample =
bits = get_bits(&s->gb, 8);
if (bits > 16 || bits < 1) {
av_log(s->avctx, AV_LOG_ERROR, "bits %d is invalid\n", bits);
return AVERROR_INVALIDDATA;
}
if (s->pegasus_rct)
bits = 9;
if (bits == 9 && !s->pegasus_rct)