blob: a124e3a123347768da4f910f394fb2c5f25469a9 [file] [log] [blame]
Patrick Williamsb48b7b42016-08-17 15:04:38 -05001From e1c0cfaa419aa5d320540d5a1b3f8fd9b82ab7e5 Mon Sep 17 00:00:00 2001
2From: Michael Niedermayer <michaelni@gmx.at>
3Date: Fri, 3 Oct 2014 16:08:32 +0200
4Subject: [PATCH] avcodec/tiff: more completely check bpp/bppcount
5
6(Upstream commit e1c0cfaa419aa5d320540d5a1b3f8fd9b82ab7e5)
7
8Fixes pixel format selection
9Fixes out of array accesses
10Fixes: asan_heap-oob_1766029_6_asan_heap-oob_20aa045_332_cov_1823216757_m2-d1d366d7965db766c19a66c7a2ccbb6b.tif
11
12Upstream-Status: Backport
13
14Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
15Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
16Signed-off-by: Yue Tao <yue.tao@windriver.com>
17---
18 libavcodec/tiff.c | 13 ++++++++++---
19 1 file changed, 10 insertions(+), 3 deletions(-)
20
21diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
22index 6e2096f..0870e31 100644
23--- a/gst-libs/ext/libav/libavcodec/tiff.c
24+++ b/gst-libs/ext/libav/libavcodec/tiff.c
25@@ -324,11 +324,11 @@ static int tiff_decode_tag(TiffContext *s, const uint8_t *start, const uint8_t *
26 s->height = value;
27 break;
28 case TIFF_BPP:
29- s->bppcount = count;
30- if(count > 4){
31- av_log(s->avctx, AV_LOG_ERROR, "This format is not supported (bpp=%d, %d components)\n", s->bpp, count);
32+ if(count > 4U){
33+ av_log(s->avctx, AV_LOG_ERROR, "This format is not supported (bpp=%d, %d components)\n", value, count);
34 return -1;
35 }
36+ s->bppcount = count;
37 if(count == 1) s->bpp = value;
38 else{
39 switch(type){
40@@ -344,6 +344,13 @@ static int tiff_decode_tag(TiffContext *s, const uint8_t *start, const uint8_t *
41 s->bpp = -1;
42 }
43 }
44+ if (s->bpp > 64U) {
45+ av_log(s->avctx, AV_LOG_ERROR,
46+ "This format is not supported (bpp=%d, %d components)\n",
47+ s->bpp, count);
48+ s->bpp = 0;
49+ return AVERROR_INVALIDDATA;
50+ }
51 break;
52 case TIFF_SAMPLES_PER_PIXEL:
53 if (count != 1) {
54--
551.7.9.5
56