diff options
author | Justin Ruggles <justin.ruggles@gmail.com> | 2011-09-14 11:39:21 -0400 |
---|---|---|
committer | Justin Ruggles <justin.ruggles@gmail.com> | 2011-10-02 10:34:39 -0400 |
commit | 5674d4b0a35a34b75e3533a8580e0b5a0a8895a7 (patch) | |
tree | 5152110723349d1eee7a6a69b378afed38845a2b | |
parent | 8290d1f38b438f1b070de67645c8b4a42014c7ac (diff) | |
download | ffmpeg-5674d4b0a35a34b75e3533a8580e0b5a0a8895a7.tar.gz |
mpc8: check output buffer size before decoding
-rw-r--r-- | libavcodec/mpc8.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/libavcodec/mpc8.c b/libavcodec/mpc8.c index 0e3947b031..a126fc8a8f 100644 --- a/libavcodec/mpc8.c +++ b/libavcodec/mpc8.c @@ -241,10 +241,16 @@ static int mpc8_decode_frame(AVCodecContext * avctx, GetBitContext gb2, *gb = &gb2; int i, j, k, ch, cnt, res, t; Band *bands = c->bands; - int off; + int off, out_size; int maxband, keyframe; int last[2]; + out_size = MPC_FRAME_SIZE * 2 * avctx->channels; + if (*data_size < out_size) { + av_log(avctx, AV_LOG_ERROR, "Output buffer is too small\n"); + return AVERROR(EINVAL); + } + keyframe = c->cur_frame == 0; if(keyframe){ @@ -400,7 +406,7 @@ static int mpc8_decode_frame(AVCodecContext * avctx, c->last_bits_used = get_bits_count(gb); if(c->cur_frame >= c->frames) c->cur_frame = 0; - *data_size = MPC_FRAME_SIZE * 2 * avctx->channels; + *data_size = out_size; return c->cur_frame ? c->last_bits_used >> 3 : buf_size; } |