avcodec/tiff: Check geotag count for being non zero
authorMichael Niedermayer <michael@niedermayer.cc>
Tue, 21 Mar 2017 00:55:01 +0000 (01:55 +0100)
committerMichael Niedermayer <michael@niedermayer.cc>
Thu, 23 Mar 2017 14:25:48 +0000 (15:25 +0100)
Fixes memleak
Fixes: 874/clusterfuzz-testcase-5252796175613952

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/targets/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavcodec/tiff.c

index 5a6573f..3aaf633 100644 (file)
@@ -1071,7 +1071,8 @@ static int tiff_decode_tag(TiffContext *s, AVFrame *frame)
             s->geotag_count = count / 4 - 1;
             av_log(s->avctx, AV_LOG_WARNING, "GeoTIFF key directory buffer shorter than specified\n");
         }
-        if (bytestream2_get_bytes_left(&s->gb) < s->geotag_count * sizeof(int16_t) * 4) {
+        if (   bytestream2_get_bytes_left(&s->gb) < s->geotag_count * sizeof(int16_t) * 4
+            || s->geotag_count == 0) {
             s->geotag_count = 0;
             return -1;
         }