diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2015-02-04 20:48:30 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2015-03-13 17:06:09 +0100 |
commit | 3a691185f732cbb5b350fbf2327817087b2a3a30 (patch) | |
tree | 8029ea407bbdeb0d411721d8513d67c2b3080e04 | |
parent | 6b4fc845f5c7b5618c3bf964ac89efc91b534093 (diff) | |
download | ffmpeg-3a691185f732cbb5b350fbf2327817087b2a3a30.tar.gz |
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 fabbfaa095660982cc0bc63242c459561fa37037)
Conflicts:
libavcodec/mjpegdec.c
-rw-r--r-- | libavcodec/mjpegdec.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c index f9d712c5d3..5a2b93b53f 100644 --- a/libavcodec/mjpegdec.c +++ b/libavcodec/mjpegdec.c @@ -439,9 +439,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 = AV_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 = AV_PIX_FMT_GRAY8; else s->avctx->pix_fmt = AV_PIX_FMT_GRAY16; |