Commit b53ed19a authored by Michael Niedermayer's avatar Michael Niedermayer

lcldec: Check length before unsigned subtraction.

Fix integer overflow and out of array read

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parent 69fb605a
...@@ -203,6 +203,10 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac ...@@ -203,6 +203,10 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac
; ;
} else if (c->flags & FLAG_MULTITHREAD) { } else if (c->flags & FLAG_MULTITHREAD) {
mthread_inlen = AV_RL32(encoded); mthread_inlen = AV_RL32(encoded);
if (len < 8) {
av_log(avctx, AV_LOG_ERROR, "len %d is too small\n", len);
return AVERROR_INVALIDDATA;
}
mthread_inlen = FFMIN(mthread_inlen, len - 8); mthread_inlen = FFMIN(mthread_inlen, len - 8);
mthread_outlen = AV_RL32(encoded+4); mthread_outlen = AV_RL32(encoded+4);
mthread_outlen = FFMIN(mthread_outlen, c->decomp_size); mthread_outlen = FFMIN(mthread_outlen, c->decomp_size);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment