Browse code

avcodec/cscd: Error out when LZ* decompression fails

Fixes: Timeout
Fixes: 6304/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CSCD_fuzzer-5754772461191168

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit d52be5d4e91871a22dac70af3e0ab429e95a2d10)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>

Michael Niedermayer authored on 2018/03/12 08:05:04
Showing 1 changed files
... ...
@@ -81,15 +81,19 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
81 81
     switch ((buf[0] >> 1) & 7) {
82 82
         case 0: { // lzo compression
83 83
             int outlen = c->decomp_size, inlen = buf_size - 2;
84
-            if (av_lzo1x_decode(c->decomp_buf, &outlen, &buf[2], &inlen))
84
+            if (av_lzo1x_decode(c->decomp_buf, &outlen, &buf[2], &inlen)) {
85 85
                 av_log(avctx, AV_LOG_ERROR, "error during lzo decompression\n");
86
+                return AVERROR_INVALIDDATA;
87
+            }
86 88
             break;
87 89
         }
88 90
         case 1: { // zlib compression
89 91
 #if CONFIG_ZLIB
90 92
             unsigned long dlen = c->decomp_size;
91
-            if (uncompress(c->decomp_buf, &dlen, &buf[2], buf_size - 2) != Z_OK)
93
+            if (uncompress(c->decomp_buf, &dlen, &buf[2], buf_size - 2) != Z_OK) {
92 94
                 av_log(avctx, AV_LOG_ERROR, "error during zlib decompression\n");
95
+                return AVERROR_INVALIDDATA;
96
+            }
93 97
             break;
94 98
 #else
95 99
             av_log(avctx, AV_LOG_ERROR, "compiled without zlib support\n");