From 936951ca5c46afe91d4efb6ce7e2759424bbe143 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Wed, 28 Mar 2012 08:05:11 +0200 Subject: [PATCH] tm2dec: check total_frames and extradata_size. Fixes overread Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind Signed-off-by: Michael Niedermayer --- libavcodec/tta.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libavcodec/tta.c b/libavcodec/tta.c index 12f1a35cf59..0b6cefb4c1d 100644 --- a/libavcodec/tta.c +++ b/libavcodec/tta.c @@ -251,11 +251,14 @@ static av_cold int tta_decode_init(AVCodecContext * avctx) av_log(s->avctx, AV_LOG_DEBUG, "data_length: %d frame_length: %d last: %d total: %d\n", s->data_length, s->frame_length, s->last_frame_length, s->total_frames); + if (s->total_frames < 0) + return AVERROR_INVALIDDATA; + // FIXME: seek table if (get_bits_left(&s->gb) < 32 * s->total_frames + 32) av_log(avctx, AV_LOG_WARNING, "Seek table missing or too small\n"); else if (avctx->err_recognition & AV_EF_CRCCHECK) { - if (tta_check_crc(s, avctx->extradata + 22, s->total_frames * 4)) + if (avctx->extradata_size < 26 + s->total_frames * 4 || tta_check_crc(s, avctx->extradata + 22, s->total_frames * 4)) return AVERROR_INVALIDDATA; } skip_bits_long(&s->gb, 32 * s->total_frames); -- 2.39.2