]> git.sesse.net Git - ffmpeg/commitdiff
avcodec/tiff: check the black level denominator
authorJames Almer <jamrial@gmail.com>
Sat, 26 Oct 2019 15:01:16 +0000 (12:01 -0300)
committerJames Almer <jamrial@gmail.com>
Tue, 29 Oct 2019 13:23:39 +0000 (10:23 -0300)
Fixes ticket #8327.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: James Almer <jamrial@gmail.com>
libavcodec/tiff.c

index f537e99b5a81ae55c185a0cae3081818b2c8e456..636614aa2806688af442aed78a2cc32513e6f887 100644 (file)
@@ -1240,6 +1240,11 @@ static int tiff_decode_tag(TiffContext *s, AVFrame *frame)
         case TIFF_RATIONAL:
             value  = ff_tget(&s->gb, TIFF_LONG, s->le);
             value2 = ff_tget(&s->gb, TIFF_LONG, s->le);
+            if (!value2) {
+                av_log(s->avctx, AV_LOG_ERROR, "Invalid denominator in rational\n");
+                return AVERROR_INVALIDDATA;
+            }
+
             break;
         case TIFF_STRING:
             if (count <= 4) {
@@ -1413,6 +1418,10 @@ static int tiff_decode_tag(TiffContext *s, AVFrame *frame)
             if (type == TIFF_RATIONAL) {
                 value  = ff_tget(&s->gb, TIFF_LONG, s->le);
                 value2 = ff_tget(&s->gb, TIFF_LONG, s->le);
+                if (!value2) {
+                    av_log(s->avctx, AV_LOG_ERROR, "Invalid black level denominator\n");
+                    return AVERROR_INVALIDDATA;
+                }
 
                 s->black_level = value / value2;
             } else