[vlc-commits] avcodec: encoder: fix buffer over-read

Thomas Guillem git at videolan.org
Wed May 23 19:14:28 CEST 2018


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Wed May 23 18:59:07 2018 +0200| [a0f4ae67a0c34691c851f7d6aef2554f17021950] | committer: Thomas Guillem

avcodec: encoder: fix buffer over-read

It happened when the mask was not the default one.

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

 modules/codec/avcodec/encoder.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/modules/codec/avcodec/encoder.c b/modules/codec/avcodec/encoder.c
index 625d9fb96f..87fff6d3c7 100644
--- a/modules/codec/avcodec/encoder.c
+++ b/modules/codec/avcodec/encoder.c
@@ -745,6 +745,7 @@ int InitVideoEnc( vlc_object_t *p_this )
          */
         const unsigned i_order_max = 8 * sizeof(p_context->channel_layout);
         uint32_t pi_order_dst[AOUT_CHAN_MAX] = { 0 };
+        uint32_t order_mask = 0;
         int i_channels_src = 0;
 
         if( p_context->channel_layout )
@@ -756,6 +757,7 @@ int InitVideoEnc( vlc_object_t *p_this )
                 {
                     msg_Dbg( p_enc, "%d %"PRIx64" mapped to %"PRIx64"", i_channels_src, pi_channels_map[i][0], pi_channels_map[i][1]);
                     pi_order_dst[i_channels_src++] = pi_channels_map[i][1];
+                    order_mask |= pi_channels_map[i][1];
                 }
             }
         }
@@ -769,14 +771,16 @@ int InitVideoEnc( vlc_object_t *p_this )
                 {
                     msg_Dbg( p_enc, "%d channel is %"PRIx64"", i_channels_src, pi_channels_map[i][1]);
                     pi_order_dst[i_channels_src++] = pi_channels_map[i][1];
+                    order_mask |= pi_channels_map[i][1];
                 }
             }
         }
         if( i_channels_src != p_context->channels )
             msg_Err( p_enc, "Channel layout not understood" );
 
-        p_sys->i_channels_to_reorder = aout_CheckChannelReorder( NULL, pi_order_dst,
-            channel_mask[p_context->channels][0], p_sys->pi_reorder_layout );
+        p_sys->i_channels_to_reorder =
+            aout_CheckChannelReorder( NULL, pi_order_dst, order_mask,
+                                      p_sys->pi_reorder_layout );
 #endif
 
         if ( p_enc->fmt_out.i_codec == VLC_CODEC_MP4A )



More information about the vlc-commits mailing list