aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2014-10-03 16:08:32 +0200
committerMichael Niedermayer <michaelni@gmx.at>2014-10-04 23:52:29 +0200
commitf6476944e1a70e1639ad45791cf94972e66ae5bb (patch)
treef1537238cb639ebc6508578fdd210cc1e38b0854
parent03d30d4c2c4d622ffd8b5603e6c41a7ca1151245 (diff)
downloadffmpeg-f6476944e1a70e1639ad45791cf94972e66ae5bb.tar.gz
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 <michaelni@gmx.at> (cherry picked from commit e1c0cfaa419aa5d320540d5a1b3f8fd9b82ab7e5) Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r--libavcodec/tiff.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
index 0352639d2f..4cb6668efb 100644
--- a/libavcodec/tiff.c
+++ b/libavcodec/tiff.c
@@ -812,13 +812,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 {
@@ -836,6 +836,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) {