From 9e7b62f0fb7462a902330fcc82cf596388f0187b Mon Sep 17 00:00:00 2001 From: Kostya Shishkov Date: Sat, 24 Aug 2013 15:00:08 +0200 Subject: twinvq: set block align for codecs and use it in size checks This both allows factoring out size check for both MetaSound and TwinVQ-VQF decoders and fixes the situation when there are several MetaSound frames stuffed together (that happens in 8kHz @ 8kbps MetaSound in ASF for example). --- libavcodec/twinvq.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'libavcodec/twinvq.c') diff --git a/libavcodec/twinvq.c b/libavcodec/twinvq.c index 17dea79ed7..24f57478f8 100644 --- a/libavcodec/twinvq.c +++ b/libavcodec/twinvq.c @@ -491,6 +491,12 @@ int ff_twinvq_decode_frame(AVCodecContext *avctx, void *data, out = (float **)frame->extended_data; } + if (buf_size < avctx->block_align) { + av_log(avctx, AV_LOG_ERROR, + "Frame too small (%d bytes). Truncated file?\n", buf_size); + return AVERROR(EINVAL); + } + if ((ret = tctx->read_bitstream(avctx, tctx, buf, buf_size)) < 0) return ret; @@ -508,7 +514,7 @@ int ff_twinvq_decode_frame(AVCodecContext *avctx, void *data, *got_frame_ptr = 1; - return buf_size; + return avctx->block_align; } /** -- cgit v1.2.3