aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2020-07-04 14:17:05 +0200
committerMichael Niedermayer <michael@niedermayer.cc>2020-07-09 12:35:39 +0200
commitb228e0c5f6a854d2ba3d5b4e3b88ab47380aacf1 (patch)
treec5a5ee2241aa91846871312e6a2045b81ea59120
parent11a10e30a92986a4666ea831976c44f9ebb4de71 (diff)
downloadffmpeg-b228e0c5f6a854d2ba3d5b4e3b88ab47380aacf1.tar.gz
avcodec/tiff: Check frame parameters before blit for DNG
Fixes: out of array access Fixes: 23888/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TIFF_fuzzer-6021365974171648.fuzz Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> (cherry picked from commit 4091f4f78012d1a7eb1e04b69cf65d5ef3afee3a) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r--libavcodec/tiff.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
index d93a02b07e..6a3ec3ef95 100644
--- a/libavcodec/tiff.c
+++ b/libavcodec/tiff.c
@@ -911,12 +911,23 @@ static int dng_decode_jpeg(AVCodecContext *avctx, AVFrame *frame,
return 0;
}
+ is_u16 = (s->bpp > 8);
+
/* Copy the outputted tile's pixels from 'jpgframe' to 'frame' (final buffer) */
/* See dng_blit for explanation */
- is_single_comp = (s->avctx_mjpeg->width == w * 2 && s->avctx_mjpeg->height == h / 2);
+ if (s->avctx_mjpeg->width == w * 2 &&
+ s->avctx_mjpeg->height == h / 2 &&
+ s->avctx_mjpeg->pix_fmt == AV_PIX_FMT_GRAY16LE) {
+ is_single_comp = 1;
+ } else if (s->avctx_mjpeg->width == w &&
+ s->avctx_mjpeg->height == h &&
+ s->avctx_mjpeg->pix_fmt == (is_u16 ? AV_PIX_FMT_GRAY16 : AV_PIX_FMT_GRAY8)
+ ) {
+ is_single_comp = 0;
+ } else
+ return AVERROR_INVALIDDATA;
- is_u16 = (s->bpp > 8);
pixel_size = (is_u16 ? sizeof(uint16_t) : sizeof(uint8_t));
if (is_single_comp && !is_u16) {