Commit fabbfaa0 authored by Michael Niedermayer's avatar Michael Niedermayer

avcodec/mjpegdec: Check number of components for JPEG-LS

Fixes out of array accesses
Fixes: asan_heap-oob_1c1a4ea_1242_cov_2274415971_TESTcmyk.jpg

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parent afa92907
...@@ -558,9 +558,12 @@ unk_pixfmt: ...@@ -558,9 +558,12 @@ unk_pixfmt:
} }
if (s->ls) { if (s->ls) {
s->upscale_h = s->upscale_v = 0; s->upscale_h = s->upscale_v = 0;
if (s->nb_components > 1) if (s->nb_components == 3) {
s->avctx->pix_fmt = AV_PIX_FMT_RGB24; s->avctx->pix_fmt = AV_PIX_FMT_RGB24;
else if (s->palette_index && s->bits <= 8) } else if (s->nb_components != 1) {
av_log(s->avctx, AV_LOG_ERROR, "Unsupported number of components %d\n", s->nb_components);
return AVERROR_PATCHWELCOME;
} else if (s->palette_index && s->bits <= 8)
s->avctx->pix_fmt = AV_PIX_FMT_PAL8; s->avctx->pix_fmt = AV_PIX_FMT_PAL8;
else if (s->bits <= 8) else if (s->bits <= 8)
s->avctx->pix_fmt = AV_PIX_FMT_GRAY8; s->avctx->pix_fmt = AV_PIX_FMT_GRAY8;
......
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