mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2025-02-20 05:46:57 +00:00
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: Michael Niedermayer <michaelni@gmx.at>
(cherry picked from commit fabbfaa095
)
Conflicts:
libavcodec/mjpegdec.c
This commit is contained in:
parent
5c0413aa85
commit
a16669f1e2
@ -418,9 +418,12 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
|
||||
}
|
||||
if (s->ls) {
|
||||
s->upscale_h = s->upscale_v = 0;
|
||||
if (s->nb_components > 1)
|
||||
if (s->nb_components == 3) {
|
||||
s->avctx->pix_fmt = PIX_FMT_RGB24;
|
||||
else if (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->bits <= 8)
|
||||
s->avctx->pix_fmt = PIX_FMT_GRAY8;
|
||||
else
|
||||
s->avctx->pix_fmt = PIX_FMT_GRAY16;
|
||||
|
Loading…
Reference in New Issue
Block a user