[02/17] vqf: Make sure the bitrate is in the valid range

Message ID 1380406879-6174-2-git-send-email-martin@martin.st
State Committed
Commit 68ff9981283a56c731f00c2ee7901103665092fc
Headers show

Commit Message

Martin Storsjö Sept. 28, 2013, 10:21 p.m.
Even if the sample rate is valid, an invalid bitrate could
pass the mode combination test below.

CC: libav-stable@libav.org
---
 libavformat/vqf.c |    7 +++++++
 1 file changed, 7 insertions(+)

Comments

Kostya Shishkov Sept. 29, 2013, 5:51 a.m. | #1
On Sun, Sep 29, 2013 at 01:21:04AM +0300, Martin Storsjö wrote:
> Even if the sample rate is valid, an invalid bitrate could
> pass the mode combination test below.
> 
> CC: libav-stable@libav.org
> ---
>  libavformat/vqf.c |    7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/libavformat/vqf.c b/libavformat/vqf.c
> index 162c753..a43829b 100644
> --- a/libavformat/vqf.c
> +++ b/libavformat/vqf.c
> @@ -182,6 +182,13 @@ static int vqf_read_header(AVFormatContext *s)
>          break;
>      }
>  
> +    if (read_bitrate / st->codec->channels <  8 ||
> +        read_bitrate / st->codec->channels > 48) {
> +        av_log(s, AV_LOG_ERROR, "Invalid bitrate per channel %d\n",
> +               read_bitrate / st->codec->channels);
> +        return AVERROR_INVALIDDATA;
> +    }
> +
>      switch (((st->codec->sample_rate/1000) << 8) +
>              read_bitrate/st->codec->channels) {
>      case (11<<8) + 8 :
> -- 

looks OK

Patch

diff --git a/libavformat/vqf.c b/libavformat/vqf.c
index 162c753..a43829b 100644
--- a/libavformat/vqf.c
+++ b/libavformat/vqf.c
@@ -182,6 +182,13 @@  static int vqf_read_header(AVFormatContext *s)
         break;
     }
 
+    if (read_bitrate / st->codec->channels <  8 ||
+        read_bitrate / st->codec->channels > 48) {
+        av_log(s, AV_LOG_ERROR, "Invalid bitrate per channel %d\n",
+               read_bitrate / st->codec->channels);
+        return AVERROR_INVALIDDATA;
+    }
+
     switch (((st->codec->sample_rate/1000) << 8) +
             read_bitrate/st->codec->channels) {
     case (11<<8) + 8 :