diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2015-05-15 17:31:58 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2015-06-10 02:13:11 +0200 |
commit | 025b38f3a6147aff2f143a930a50b377ad4a60f8 (patch) | |
tree | d64227a3e5a3188d2eb474affa2fe90d5449c66b | |
parent | 41c81556a70cd32fc153a614a2088a926b779b39 (diff) | |
download | ffmpeg-025b38f3a6147aff2f143a930a50b377ad4a60f8.tar.gz |
avcodec/sonic: More completely check sample_rate_index and channels
Fixes CID1271783
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
(cherry picked from commit ade8a46154cb45c88b1cb5c616eaa6320c941187)
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r-- | libavcodec/sonic.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/libavcodec/sonic.c b/libavcodec/sonic.c index 7a9db36311..2621be41cf 100644 --- a/libavcodec/sonic.c +++ b/libavcodec/sonic.c @@ -769,13 +769,19 @@ static av_cold int sonic_decode_init(AVCodecContext *avctx) if (version == 1) { + int sample_rate_index; s->channels = get_bits(&gb, 2); - s->samplerate = samplerate_table[get_bits(&gb, 4)]; + sample_rate_index = get_bits(&gb, 4); + if (sample_rate_index >= FF_ARRAY_ELEMS(samplerate_table)) { + av_log(avctx, AV_LOG_ERROR, "Invalid sample_rate_index %d\n", sample_rate_index); + return AVERROR_INVALIDDATA; + } + s->samplerate = samplerate_table[sample_rate_index]; av_log(avctx, AV_LOG_INFO, "Sonicv2 chans: %d samprate: %d\n", s->channels, s->samplerate); } - if (s->channels > MAX_CHANNELS) + if (s->channels > MAX_CHANNELS || s->channels < 1) { av_log(avctx, AV_LOG_ERROR, "Only mono and stereo streams are supported by now\n"); return AVERROR_INVALIDDATA; |