Commit 0db1f2c2 authored by Michael Niedermayer's avatar Michael Niedermayer

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: 's avatarMichael Niedermayer <michaelni@gmx.at>
parent 903156aa
...@@ -256,6 +256,11 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s) ...@@ -256,6 +256,11 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
s->avctx->bits_per_raw_sample = s->avctx->bits_per_raw_sample =
bits = get_bits(&s->gb, 8); 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) if (s->pegasus_rct)
bits = 9; bits = 9;
if (bits == 9 && !s->pegasus_rct) if (bits == 9 && !s->pegasus_rct)
......
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