]> git.sesse.net Git - ffmpeg/commitdiff
avcodec/tiff: Some checks on bpp for DNG
authorMichael Niedermayer <michael@niedermayer.cc>
Sat, 15 Feb 2020 15:19:08 +0000 (16:19 +0100)
committerMichael Niedermayer <michael@niedermayer.cc>
Wed, 29 Apr 2020 21:42:35 +0000 (23:42 +0200)
dng spec 1.5.0.0
"BitsPerSample
Supported values are from 8 to 32 bits/sample. The depth must be the same for each sample if
SamplesPerPixel is not equal to 1."

Fixes: eg_crash
Found-by: 黄宁 <tsukimurarin@163.com>
Reviewed-by: Nick Renieris <velocityra@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavcodec/tiff.c

index 3b5985ed1e576d2b0cefd15caeafc87e8c76dbd2..5bdcac2006a415345ecf825f92bfd9dec5f00eb2 100644 (file)
@@ -1858,6 +1858,8 @@ again:
     }
 
     if (is_dng) {
+        int bps;
+
         if (s->white_level == 0)
             s->white_level = (1 << s->bpp) - 1; /* Default value as per the spec */
 
@@ -1866,6 +1868,12 @@ again:
                 s->black_level, s->white_level);
             return AVERROR_INVALIDDATA;
         }
+
+        if (s->bpp % s->bppcount)
+            return AVERROR_INVALIDDATA;
+        bps = s->bpp / s->bppcount;
+        if (bps < 8 || bps > 32)
+            return AVERROR_INVALIDDATA;
     }
 
     if (!s->is_tiled && !s->strippos && !s->stripoff) {