[FFmpeg-cvslog] avcodec/tiff: more completely check bpp/bppcount

Michael Niedermayer git at videolan.org
Sun Dec 21 04:50:28 CET 2014


ffmpeg | branch: release/1.1 | Michael Niedermayer <michaelni at gmx.at> | Fri Oct  3 16:08:32 2014 +0200| [aa17021e812eb2527033d85ba0390cc4f7d6c9d5] | committer: Michael Niedermayer

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 at gmx.at>
(cherry picked from commit e1c0cfaa419aa5d320540d5a1b3f8fd9b82ab7e5)

Conflicts:

	libavcodec/tiff.c

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=aa17021e812eb2527033d85ba0390cc4f7d6c9d5
---

 libavcodec/tiff.c |   13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
index 7394655..d85a7d1 100644
--- a/libavcodec/tiff.c
+++ b/libavcodec/tiff.c
@@ -720,13 +720,13 @@ static int tiff_decode_tag(TiffContext *s)
         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 -1;
         }
+        s->bppcount = count;
         if (count == 1)
             s->bpp = value;
         else {
@@ -747,6 +747,13 @@ static int tiff_decode_tag(TiffContext *s)
                 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) {



More information about the ffmpeg-cvslog mailing list