@@ -68,13 +68,14 @@ static int remap_c16(const struct audio_stream *source, uint32_t dummy1,
6868 src_channel = chmap & 0xf ;
6969 chmap >>= 4 ;
7070
71- if (src_channel == 0xf ) {
71+ /* 0xf means "mute"; also mute any out-of-range source channel so
72+ * a crafted chmap nibble cannot index past the source frame.
73+ */
74+ if (src_channel == 0xf || src_channel >= num_src_channels ) {
7275 mute_channel_c16 (sink , sink_channel , frames );
7376 continue ;
7477 }
7578
76- assert (src_channel < num_src_channels );
77-
7879 src = (int16_t * )audio_stream_get_rptr (source ) + src_channel ;
7980 dst = (int16_t * )audio_stream_get_wptr (sink ) + sink_channel ;
8081
@@ -126,13 +127,14 @@ static inline int remap_c32_left_shift(const struct audio_stream *source,
126127 src_channel = chmap & 0xf ;
127128 chmap >>= 4 ;
128129
129- if (src_channel == 0xf ) {
130+ /* 0xf means "mute"; also mute any out-of-range source channel so
131+ * a crafted chmap nibble cannot index past the source frame.
132+ */
133+ if (src_channel == 0xf || src_channel >= num_src_channels ) {
130134 mute_channel_c32 (sink , sink_channel , frames );
131135 continue ;
132136 }
133137
134- assert (src_channel < num_src_channels );
135-
136138 src = (int32_t * )audio_stream_get_rptr (source ) + src_channel ;
137139 dst = (int32_t * )audio_stream_get_wptr (sink ) + sink_channel ;
138140
@@ -184,13 +186,14 @@ static inline int remap_c32_right_shift(const struct audio_stream *source,
184186 src_channel = chmap & 0xf ;
185187 chmap >>= 4 ;
186188
187- if (src_channel == 0xf ) {
189+ /* 0xf means "mute"; also mute any out-of-range source channel so
190+ * a crafted chmap nibble cannot index past the source frame.
191+ */
192+ if (src_channel == 0xf || src_channel >= num_src_channels ) {
188193 mute_channel_c32 (sink , sink_channel , frames );
189194 continue ;
190195 }
191196
192- assert (src_channel < num_src_channels );
193-
194197 src = (int32_t * )audio_stream_get_rptr (source ) + src_channel ;
195198 dst = (int32_t * )audio_stream_get_wptr (sink ) + sink_channel ;
196199
@@ -243,13 +246,14 @@ static inline int remap_c16_to_c32(const struct audio_stream *source,
243246 src_channel = chmap & 0xf ;
244247 chmap >>= 4 ;
245248
246- if (src_channel == 0xf ) {
249+ /* 0xf means "mute"; also mute any out-of-range source channel so
250+ * a crafted chmap nibble cannot index past the source frame.
251+ */
252+ if (src_channel == 0xf || src_channel >= num_src_channels ) {
247253 mute_channel_c32 (sink , sink_channel , frames );
248254 continue ;
249255 }
250256
251- assert (src_channel < num_src_channels );
252-
253257 src = (int16_t * )audio_stream_get_rptr (source ) + src_channel ;
254258 dst = (int32_t * )audio_stream_get_wptr (sink ) + sink_channel ;
255259
@@ -302,13 +306,14 @@ static inline int remap_c32_to_c16(const struct audio_stream *source,
302306 src_channel = chmap & 0xf ;
303307 chmap >>= 4 ;
304308
305- if (src_channel == 0xf ) {
309+ /* 0xf means "mute"; also mute any out-of-range source channel so
310+ * a crafted chmap nibble cannot index past the source frame.
311+ */
312+ if (src_channel == 0xf || src_channel >= num_src_channels ) {
306313 mute_channel_c16 (sink , sink_channel , frames );
307314 continue ;
308315 }
309316
310- assert (src_channel < num_src_channels );
311-
312317 src = (int32_t * )audio_stream_get_rptr (source ) + src_channel ;
313318 dst = (int16_t * )audio_stream_get_wptr (sink ) + sink_channel ;
314319
0 commit comments