[FFmpeg-cvslog] oma: Validate sample rates

Luca Barbato git at videolan.org
Sun May 12 12:55:42 CEST 2013


ffmpeg | branch: release/1.1 | Luca Barbato <lu_zero at gentoo.org> | Sat Mar 30 09:46:06 2013 +0100| [c0f7df96627741c737022738ef4260beb85bf69c] | committer: Reinhard Tartler

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 at libav.org
(cherry picked from commit 0933fd1533560fbc718026e12f19a4824b041237)

Signed-off-by: Reinhard Tartler <siretart at tauware.de>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c0f7df96627741c737022738ef4260beb85bf69c
---

 libavformat/oma.c    |    2 +-
 libavformat/oma.h    |    2 +-
 libavformat/omadec.c |   17 +++++++++++++----
 3 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/libavformat/oma.c b/libavformat/oma.c
index f6454d9..aaaf0b2 100644
--- a/libavformat/oma.c
+++ b/libavformat/oma.c
@@ -22,7 +22,7 @@
 #include "oma.h"
 #include "libavcodec/avcodec.h"
 
-const uint16_t ff_oma_srate_tab[6] = { 320, 441, 480, 882, 960, 0 };
+const uint16_t ff_oma_srate_tab[8] = { 320, 441, 480, 882, 960, 0 };
 
 const AVCodecTag ff_oma_codec_tags[] = {
     { AV_CODEC_ID_ATRAC3,      OMA_CODECID_ATRAC3  },
diff --git a/libavformat/oma.h b/libavformat/oma.h
index bac8bcb..1f0ddf9 100644
--- a/libavformat/oma.h
+++ b/libavformat/oma.h
@@ -37,7 +37,7 @@ enum {
     OMA_CODECID_WMA     = 5,
 };
 
-extern const uint16_t ff_oma_srate_tab[6];
+extern const uint16_t ff_oma_srate_tab[8];
 
 extern const AVCodecTag ff_oma_codec_tags[];
 
diff --git a/libavformat/omadec.c b/libavformat/omadec.c
index 2e565c1..f6b6f13 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)
                 av_log_ask_for_sample(s, "Unsupported sample rate: %d\n",
                                       samplerate);
@@ -335,9 +339,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:



More information about the ffmpeg-cvslog mailing list