[09/17] electronicarts: Add more sanity checking for the number of channels

Message ID 1380406879-6174-9-git-send-email-martin@martin.st
State Committed
Headers show

Commit Message

Martin Storsjö Sept. 28, 2013, 10:21 p.m.
Reported-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
CC: libav-stable@libav.org
---
 libavformat/electronicarts.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Kostya Shishkov Sept. 29, 2013, 6:02 a.m. | #1
On Sun, Sep 29, 2013 at 01:21:11AM +0300, Martin Storsjö wrote:
> Reported-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
> CC: libav-stable@libav.org
> ---
>  libavformat/electronicarts.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavformat/electronicarts.c b/libavformat/electronicarts.c
> index b0e0674..b518ca0 100644
> --- a/libavformat/electronicarts.c
> +++ b/libavformat/electronicarts.c
> @@ -467,7 +467,7 @@ static int ea_read_header(AVFormatContext *s)
>      }
>  
>      if (ea->audio_codec) {
> -        if (ea->num_channels <= 0) {
> +        if (ea->num_channels <= 0 || ea->num_channels > 48) {
>              av_log(s, AV_LOG_WARNING,
>                     "Unsupported number of channels: %d\n", ea->num_channels);
>              ea->audio_codec = 0;
> -- 

probably OK though I doubt they had such multi-channel codecs
Martin Storsjö Sept. 29, 2013, 9:53 a.m. | #2
On Sun, 29 Sep 2013, Kostya Shishkov wrote:

> On Sun, Sep 29, 2013 at 01:21:11AM +0300, Martin Storsjö wrote:
>> Reported-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
>> CC: libav-stable@libav.org
>> ---
>>  libavformat/electronicarts.c |    2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/libavformat/electronicarts.c b/libavformat/electronicarts.c
>> index b0e0674..b518ca0 100644
>> --- a/libavformat/electronicarts.c
>> +++ b/libavformat/electronicarts.c
>> @@ -467,7 +467,7 @@ static int ea_read_header(AVFormatContext *s)
>>      }
>>
>>      if (ea->audio_codec) {
>> -        if (ea->num_channels <= 0) {
>> +        if (ea->num_channels <= 0 || ea->num_channels > 48) {
>>              av_log(s, AV_LOG_WARNING,
>>                     "Unsupported number of channels: %d\n", ea->num_channels);
>>              ea->audio_codec = 0;
>> --
>
> probably OK though I doubt they had such multi-channel codecs

Probably not - I guess 2 is the maximum used in practice? Lowering the 
limit to 2 passes fate at least...

// Martin
Kostya Shishkov Sept. 29, 2013, 11:12 a.m. | #3
On Sun, Sep 29, 2013 at 12:53:31PM +0300, Martin Storsjö wrote:
> On Sun, 29 Sep 2013, Kostya Shishkov wrote:
> 
> >On Sun, Sep 29, 2013 at 01:21:11AM +0300, Martin Storsjö wrote:
> >>Reported-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
> >>CC: libav-stable@libav.org
> >>---
> >> libavformat/electronicarts.c |    2 +-
> >> 1 file changed, 1 insertion(+), 1 deletion(-)
> >>
> >>diff --git a/libavformat/electronicarts.c b/libavformat/electronicarts.c
> >>index b0e0674..b518ca0 100644
> >>--- a/libavformat/electronicarts.c
> >>+++ b/libavformat/electronicarts.c
> >>@@ -467,7 +467,7 @@ static int ea_read_header(AVFormatContext *s)
> >>     }
> >>
> >>     if (ea->audio_codec) {
> >>-        if (ea->num_channels <= 0) {
> >>+        if (ea->num_channels <= 0 || ea->num_channels > 48) {
> >>             av_log(s, AV_LOG_WARNING,
> >>                    "Unsupported number of channels: %d\n", ea->num_channels);
> >>             ea->audio_codec = 0;
> >>--
> >
> >probably OK though I doubt they had such multi-channel codecs
> 
> Probably not - I guess 2 is the maximum used in practice? Lowering
> the limit to 2 passes fate at least...

A quick look at multimedia wiki does not show any surround audio format for EA
files, so 2 channels should be enough.

Patch

diff --git a/libavformat/electronicarts.c b/libavformat/electronicarts.c
index b0e0674..b518ca0 100644
--- a/libavformat/electronicarts.c
+++ b/libavformat/electronicarts.c
@@ -467,7 +467,7 @@  static int ea_read_header(AVFormatContext *s)
     }
 
     if (ea->audio_codec) {
-        if (ea->num_channels <= 0) {
+        if (ea->num_channels <= 0 || ea->num_channels > 48) {
             av_log(s, AV_LOG_WARNING,
                    "Unsupported number of channels: %d\n", ea->num_channels);
             ea->audio_codec = 0;