[01/11] dcadec: Validate the lfe parameter

Message ID 1379599756-27062-1-git-send-email-martin@martin.st
State Committed
Headers show

Commit Message

Martin Storsjö Sept. 19, 2013, 2:09 p.m.
We only seem to support values 1 and 2 (and 0 for it being disabled)
according to how I interpret lfe_interpolation_fir.

Reported-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
CC: libav-stable@libav.org
---
 libavcodec/dcadec.c |    5 +++++
 1 file changed, 5 insertions(+)

Comments

Luca Barbato Sept. 19, 2013, 2:27 p.m. | #1
On 19/09/13 16:09, Martin Storsjö wrote:
> We only seem to support values 1 and 2 (and 0 for it being disabled)
> according to how I interpret lfe_interpolation_fir.
> 

While at it print the value read please.

lu
Martin Storsjö Sept. 20, 2013, 7:20 a.m. | #2
On Thu, 19 Sep 2013, Martin Storsjö wrote:

> We only seem to support values 1 and 2 (and 0 for it being disabled)
> according to how I interpret lfe_interpolation_fir.
>
> Reported-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
> CC: libav-stable@libav.org
> ---
> libavcodec/dcadec.c |    5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/libavcodec/dcadec.c b/libavcodec/dcadec.c
> index 209bca3..24bdb7e 100644
> --- a/libavcodec/dcadec.c
> +++ b/libavcodec/dcadec.c
> @@ -580,6 +580,11 @@ static int dca_parse_frame_header(DCAContext *s)
>     s->lfe               = get_bits(&s->gb, 2);
>     s->predictor_history = get_bits(&s->gb, 1);
>
> +    if (s->lfe > 2) {
> +        avpriv_request_sample(s->avctx, "LFE > 2");
> +        return AVERROR_PATCHWELCOME;
> +    }
> +
>     /* TODO: check CRC */
>     if (s->crc_present)
>         s->header_crc    = get_bits(&s->gb, 16);
> -- 
> 1.7.9.5

According to Kostya, lfe == 3 (which is the only other possible case when 
it's read from 2 bits) is disallowed by the spec completely, so I'll 
change it to INVALIDDATA and change the log message a little before 
pushing.

// Martin

Patch

diff --git a/libavcodec/dcadec.c b/libavcodec/dcadec.c
index 209bca3..24bdb7e 100644
--- a/libavcodec/dcadec.c
+++ b/libavcodec/dcadec.c
@@ -580,6 +580,11 @@  static int dca_parse_frame_header(DCAContext *s)
     s->lfe               = get_bits(&s->gb, 2);
     s->predictor_history = get_bits(&s->gb, 1);
 
+    if (s->lfe > 2) {
+        avpriv_request_sample(s->avctx, "LFE > 2");
+        return AVERROR_PATCHWELCOME;
+    }
+
     /* TODO: check CRC */
     if (s->crc_present)
         s->header_crc    = get_bits(&s->gb, 16);