avcodec/dxv: Check remaining bytes in dxv_decompress_raw()
authorMichael Niedermayer <michael@niedermayer.cc>
Sun, 4 Jun 2017 13:41:18 +0000 (15:41 +0200)
committerMichael Niedermayer <michael@niedermayer.cc>
Mon, 5 Jun 2017 01:31:29 +0000 (03:31 +0200)
Fixes: Timeout
Fixes: 2006/clusterfuzz-testcase-minimized-5766515037044736

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 eb5049227033d946add93c0714bb8a28d94166f1)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavcodec/dxv.c

index 05a9aad..f194b13 100644 (file)
@@ -331,6 +331,9 @@ static int dxv_decompress_raw(AVCodecContext *avctx)
     DXVContext *ctx = avctx->priv_data;
     GetByteContext *gbc = &ctx->gbc;
 
+    if (bytestream2_get_bytes_left(gbc) < ctx->tex_size)
+        return AVERROR_INVALIDDATA;
+
     bytestream2_get_buffer(gbc, ctx->tex_data, ctx->tex_size);
     return 0;
 }