aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Almer <jamrial@gmail.com>2016-05-10 22:07:19 -0300
committerJames Almer <jamrial@gmail.com>2016-05-10 22:07:19 -0300
commitb2244fa0a624f7e38893d58265e9c039bed2e4de (patch)
tree200db6adfaefc38b7d82f532299c1d59c27a9c9d
parent6c44696b3d504eb87d60915919074da530cd379f (diff)
downloadffmpeg-b2244fa0a624f7e38893d58265e9c039bed2e4de.tar.gz
avcodec/rscc: check input buffer size for deflate mode
Fixes overreads. Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: James Almer <jamrial@gmail.com>
-rw-r--r--libavcodec/rscc.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/libavcodec/rscc.c b/libavcodec/rscc.c
index a47d29fe0a..fe0df2eec1 100644
--- a/libavcodec/rscc.c
+++ b/libavcodec/rscc.c
@@ -248,6 +248,12 @@ static int rscc_decode_frame(AVCodecContext *avctx, void *data,
ff_dlog(avctx, "pixel_size %d packed_size %d.\n", pixel_size, packed_size);
+ if (packed_size < 0) {
+ av_log(avctx, AV_LOG_ERROR, "Invalid tile size %d\n", packed_size);
+ ret = AVERROR_INVALIDDATA;
+ goto end;
+ }
+
/* Get pixels buffer, it may be deflated or just raw */
if (pixel_size == packed_size) {
if (bytestream2_get_bytes_left(gbc) < pixel_size) {
@@ -258,6 +264,11 @@ static int rscc_decode_frame(AVCodecContext *avctx, void *data,
pixels = gbc->buffer;
} else {
uLongf len = ctx->inflated_size;
+ if (bytestream2_get_bytes_left(gbc) < packed_size) {
+ av_log(avctx, AV_LOG_ERROR, "Insufficient input for %d\n", packed_size);
+ ret = AVERROR_INVALIDDATA;
+ goto end;
+ }
ret = uncompress(ctx->inflated_buf, &len, gbc->buffer, packed_size);
if (ret) {
av_log(avctx, AV_LOG_ERROR, "Pixel deflate error %d.\n", ret);