diff options
author | Luca Barbato <lu_zero@gentoo.org> | 2013-03-30 12:46:06 +0400 |
---|---|---|
committer | Luca Barbato <lu_zero@gentoo.org> | 2013-03-31 18:10:52 +0400 |
commit | 0933fd1533560fbc718026e12f19a4824b041237 (patch) | |
tree | 46d1fe4668a882491bcd8ea6519d0284e7cfa9a5 /libavformat/omadec.c | |
parent | f2f57d16795efa8083acef17c640bea6c08aa638 (diff) |
oma: Validate sample rates
The sample rate index is 3 bits even if currently index 5, 6 and 7 are
not supported.
Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
CC: libav-stable@libav.org
Diffstat (limited to 'libavformat/omadec.c')
-rw-r--r-- | libavformat/omadec.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/libavformat/omadec.c b/libavformat/omadec.c index 6d6d311a81..0603aa27b5 100644 --- a/libavformat/omadec.c +++ b/libavformat/omadec.c @@ -304,7 +304,11 @@ static int oma_read_header(AVFormatContext *s) switch (buf[32]) { case OMA_CODECID_ATRAC3: - samplerate = ff_oma_srate_tab[(codec_params >> 13) & 7]*100; + samplerate = ff_oma_srate_tab[(codec_params >> 13) & 7] * 100; + if (!samplerate) { + av_log(s, AV_LOG_ERROR, "Unsupported sample rate\n"); + return AVERROR_INVALIDDATA; + } if (samplerate != 44100) avpriv_request_sample(s, "Sample rate %d", samplerate); @@ -334,9 +338,14 @@ static int oma_read_header(AVFormatContext *s) case OMA_CODECID_ATRAC3P: st->codec->channels = (codec_params >> 10) & 7; framesize = ((codec_params & 0x3FF) * 8) + 8; - st->codec->sample_rate = ff_oma_srate_tab[(codec_params >> 13) & 7]*100; - st->codec->bit_rate = st->codec->sample_rate * framesize * 8 / 1024; - avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate); + samplerate = ff_oma_srate_tab[(codec_params >> 13) & 7] * 100; + if (!samplerate) { + av_log(s, AV_LOG_ERROR, "Unsupported sample rate\n"); + return AVERROR_INVALIDDATA; + } + st->codec->sample_rate = samplerate; + st->codec->bit_rate = samplerate * framesize * 8 / 1024; + avpriv_set_pts_info(st, 64, 1, samplerate); av_log(s, AV_LOG_ERROR, "Unsupported codec ATRAC3+!\n"); break; case OMA_CODECID_MP3: |