[1/2] dca: Validate the channel map

Message ID 20170314091530.3343-1-lu_zero@gentoo.org
State New
Headers show

Commit Message

Luca Barbato March 14, 2017, 9:15 a.m.
Having a mismatch between the number of channels in the stream and those
in the channel map will lead to a segfault or worse.

Bug-Id: 1016

CC: libav-stable@libav.org
---
Description updated.

 libavcodec/dcadec.c | 3 +++
 1 file changed, 3 insertions(+)

--
2.11.1

Comments

Diego Biurrun March 16, 2017, 3:53 p.m. | #1
On Tue, Mar 14, 2017 at 09:15:29AM +0000, Luca Barbato wrote:
> Having a mismatch between the number of channels in the stream and those
> in the channel map will lead to a segfault or worse.
> 
> Bug-Id: 1016
> 
> CC: libav-stable@libav.org
> ---
> Description updated.
> 
>  libavcodec/dcadec.c | 3 +++
>  1 file changed, 3 insertions(+)

probably OK

Diego

Patch

diff --git a/libavcodec/dcadec.c b/libavcodec/dcadec.c
index cd4432368c..af26dceafd 100644
--- a/libavcodec/dcadec.c
+++ b/libavcodec/dcadec.c
@@ -1297,6 +1297,9 @@  static int set_channel_layout(AVCodecContext *avctx, int channels, int num_core_
                 s->channel_order_tab = ff_dca_channel_reorder_nolfe[s->amode];
         }

+        if (channels < ff_dca_channels[s->amode])
+            return AVERROR_INVALIDDATA;
+
         if (channels > !!s->lfe &&
             s->channel_order_tab[channels - 1 - !!s->lfe] < 0)
             return AVERROR_INVALIDDATA;