[FFmpeg-cvslog] avcodec/sonic: More completely check sample_rate_index and channels
Michael Niedermayer
git at videolan.org
Wed Jun 17 22:09:44 CEST 2015
ffmpeg | branch: release/2.2 | Michael Niedermayer <michaelni at gmx.at> | Fri May 15 17:31:58 2015 +0200| [3344a28787a72533f322e1f6f5bc6fd07597d870] | committer: Michael Niedermayer
avcodec/sonic: More completely check sample_rate_index and channels
Fixes CID1271783
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
(cherry picked from commit ade8a46154cb45c88b1cb5c616eaa6320c941187)
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=3344a28787a72533f322e1f6f5bc6fd07597d870
---
libavcodec/sonic.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/libavcodec/sonic.c b/libavcodec/sonic.c
index 61f8114..c5076f9 100644
--- a/libavcodec/sonic.c
+++ b/libavcodec/sonic.c
@@ -883,13 +883,19 @@ static av_cold int sonic_decode_init(AVCodecContext *avctx)
if (s->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;
More information about the ffmpeg-cvslog
mailing list