aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2019-09-12 21:13:11 +0200
committerMichael Niedermayer <michael@niedermayer.cc>2019-09-13 21:53:27 +0200
commit3b5ce76b1a68430f07645eaebe77946116977dbb (patch)
treee0303953e27da091959c30f550f6edbc2a2aa2d1
parent2006e5ccb6db3d4fd97096d8a1d0ba18f708f5fe (diff)
downloadffmpeg-3b5ce76b1a68430f07645eaebe77946116977dbb.tar.gz
avcodec/mjpegdec: Restore non bayer checks in ljpeg_decode_rgb_scan()
Fixes: out of array write Fixes: 17088/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_JPEGLS_fuzzer-5654877765632000 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r--libavcodec/mjpegdec.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
index 5a80b7d289..f095afaed8 100644
--- a/libavcodec/mjpegdec.c
+++ b/libavcodec/mjpegdec.c
@@ -1071,6 +1071,10 @@ static int ljpeg_decode_rgb_scan(MJpegDecodeContext *s, int nb_components, int p
int resync_mb_x = 0;
int vpred[6];
+ if (!s->bayer && s->nb_components < 3)
+ return AVERROR_INVALIDDATA;
+ if (s->bayer && s->nb_components > 2)
+ return AVERROR_INVALIDDATA;
if (s->nb_components <= 0 || s->nb_components > 4)
return AVERROR_INVALIDDATA;
if (s->v_max != 1 || s->h_max != 1 || !s->lossless)