From: Michael Niedermayer Date: Fri, 3 Oct 2014 14:08:32 +0000 (+0200) Subject: avcodec/tiff: more completely check bpp/bppcount X-Git-Tag: android-x86-4.4-r2^2~37 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=ceb9d67a0ad1a4076ef349c8756ce8b732d03a34;p=android-x86%2Fexternal-ffmpeg.git avcodec/tiff: more completely check bpp/bppcount Fixes pixel format selection Fixes out of array accesses Fixes: asan_heap-oob_1766029_6_asan_heap-oob_20aa045_332_cov_1823216757_m2-d1d366d7965db766c19a66c7a2ccbb6b.tif Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind Signed-off-by: Michael Niedermayer (cherry picked from commit e1c0cfaa419aa5d320540d5a1b3f8fd9b82ab7e5) Signed-off-by: Michael Niedermayer --- diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c index 80c6d6e376..cedab34970 100644 --- a/libavcodec/tiff.c +++ b/libavcodec/tiff.c @@ -604,13 +604,13 @@ static int tiff_decode_tag(TiffContext *s, AVFrame *frame) s->height = value; break; case TIFF_BPP: - s->bppcount = count; - if (count > 4) { + if (count > 4U) { av_log(s->avctx, AV_LOG_ERROR, "This format is not supported (bpp=%d, %d components)\n", - s->bpp, count); + value, count); return AVERROR_INVALIDDATA; } + s->bppcount = count; if (count == 1) s->bpp = value; else { @@ -628,6 +628,13 @@ static int tiff_decode_tag(TiffContext *s, AVFrame *frame) s->bpp = -1; } } + if (s->bpp > 64U) { + av_log(s->avctx, AV_LOG_ERROR, + "This format is not supported (bpp=%d, %d components)\n", + s->bpp, count); + s->bpp = 0; + return AVERROR_INVALIDDATA; + } break; case TIFF_SAMPLES_PER_PIXEL: if (count != 1) {