]> git.sesse.net Git - ffmpeg/commitdiff
avcodec/fitsdec: Check data_min/max
authorMichael Niedermayer <michael@niedermayer.cc>
Wed, 12 Jun 2019 22:24:53 +0000 (00:24 +0200)
committerMichael Niedermayer <michael@niedermayer.cc>
Sun, 30 Jun 2019 12:27:04 +0000 (14:27 +0200)
Fixes: division by 0
Fixes: 15206/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_FITS_fuzzer-5657260212092928
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavcodec/fitsdec.c

index 67a8bd71f4be22b604bd1a5624721b00182153b2..4f452422efd60783a59fe809c649dfb7a55b62c3 100644 (file)
@@ -168,6 +168,14 @@ static int fits_read_header(AVCodecContext *avctx, const uint8_t **ptr, FITSHead
         header->data_min = (header->data_min - header->bzero) / header->bscale;
         header->data_max = (header->data_max - header->bzero) / header->bscale;
     }
+    if (!header->rgb && header->data_min >= header->data_max) {
+        if (header->data_min > header->data_max) {
+            av_log(avctx, AV_LOG_ERROR, "data min/max (%g %g) is invalid\n", header->data_min, header->data_max);
+            return AVERROR_INVALIDDATA;
+        }
+        av_log(avctx, AV_LOG_WARNING, "data min/max indicates a blank image\n");
+        header->data_max ++;
+    }
 
     return 0;
 }