summaryrefslogtreecommitdiff
path: root/libavcodec/tta.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2012-03-28 08:05:11 +0200
committerMichael Niedermayer <michaelni@gmx.at>2012-03-28 08:24:31 +0200
commit936951ca5c46afe91d4efb6ce7e2759424bbe143 (patch)
tree7e5c9b6809ff7fc22b10ee8d248b26ca598dc041 /libavcodec/tta.c
parentb17b2963692f5f7c19a2188e61922e00680c5fb4 (diff)
tm2dec: check total_frames and extradata_size.
Fixes overread Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/tta.c')
-rw-r--r--libavcodec/tta.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/libavcodec/tta.c b/libavcodec/tta.c
index 12f1a35cf5..0b6cefb4c1 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);