aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/mjpegdec.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2015-02-04 20:48:30 +0100
committerMichael Niedermayer <michaelni@gmx.at>2015-02-17 19:43:18 +0100
commit4c246c65bfa221c45452923cf148f7b11245b6d5 (patch)
tree39189c1fd1abafb29977b131547e298e9ced0649 /libavcodec/mjpegdec.c
parentb0d3873085253f9e60afe256c3b0368c3ab7dd07 (diff)
downloadffmpeg-4c246c65bfa221c45452923cf148f7b11245b6d5.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
Diffstat (limited to 'libavcodec/mjpegdec.c')
-rw-r--r--libavcodec/mjpegdec.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
index 8289cc5d7c..bd12c7bb9b 100644
--- a/libavcodec/mjpegdec.c
+++ b/libavcodec/mjpegdec.c
@@ -495,9 +495,12 @@ unk_pixfmt:
}
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;