mirror of
https://gitlab.freedesktop.org/pipewire/wireplumber.git
synced 2025-12-20 06:30:04 +01:00
m-si-audio-adapter: don't overread the position array
Limit the amount of channels we read from and write to the position array with SPA_N_ELEMENTS(). The number of channels might be larger than what we have positions for.
This commit is contained in:
parent
e30c2a7cd9
commit
ee72196500
1 changed files with 6 additions and 4 deletions
|
|
@ -137,10 +137,11 @@ si_audio_adapter_get_default_clock_rate (WpSiAudioAdapter * self)
|
||||||
static gboolean
|
static gboolean
|
||||||
is_unpositioned (struct spa_audio_info_raw *info)
|
is_unpositioned (struct spa_audio_info_raw *info)
|
||||||
{
|
{
|
||||||
uint32_t i;
|
uint32_t i, n_pos;
|
||||||
if (SPA_FLAG_IS_SET(info->flags, SPA_AUDIO_FLAG_UNPOSITIONED))
|
if (SPA_FLAG_IS_SET(info->flags, SPA_AUDIO_FLAG_UNPOSITIONED))
|
||||||
return TRUE;
|
return TRUE;
|
||||||
for (i = 0; i < info->channels; i++)
|
n_pos = SPA_MIN(info->channels, SPA_N_ELEMENTS(info->position));
|
||||||
|
for (i = 0; i < n_pos; i++)
|
||||||
if (info->position[i] >= SPA_AUDIO_CHANNEL_START_Aux &&
|
if (info->position[i] >= SPA_AUDIO_CHANNEL_START_Aux &&
|
||||||
info->position[i] <= SPA_AUDIO_CHANNEL_LAST_Aux)
|
info->position[i] <= SPA_AUDIO_CHANNEL_LAST_Aux)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
@ -197,7 +198,7 @@ si_audio_adapter_find_format (WpSiAudioAdapter * self, WpNode * node,
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (position == NULL ||
|
if (position == NULL ||
|
||||||
!spa_pod_copy_array(position, SPA_TYPE_Id, raw_format.position, SPA_AUDIO_MAX_CHANNELS))
|
!spa_pod_copy_array(position, SPA_TYPE_Id, raw_format.position, SPA_N_ELEMENTS(raw_format.position)))
|
||||||
SPA_FLAG_SET(raw_format.flags, SPA_AUDIO_FLAG_UNPOSITIONED);
|
SPA_FLAG_SET(raw_format.flags, SPA_AUDIO_FLAG_UNPOSITIONED);
|
||||||
|
|
||||||
if (mono) {
|
if (mono) {
|
||||||
|
|
@ -349,7 +350,8 @@ format_audio_raw_build (const struct spa_audio_info_raw *info)
|
||||||
if (!SPA_FLAG_IS_SET (info->flags, SPA_AUDIO_FLAG_UNPOSITIONED)) {
|
if (!SPA_FLAG_IS_SET (info->flags, SPA_AUDIO_FLAG_UNPOSITIONED)) {
|
||||||
/* Build the position array spa pod */
|
/* Build the position array spa pod */
|
||||||
g_autoptr (WpSpaPodBuilder) position_builder = wp_spa_pod_builder_new_array ();
|
g_autoptr (WpSpaPodBuilder) position_builder = wp_spa_pod_builder_new_array ();
|
||||||
for (guint i = 0; i < info->channels; i++)
|
guint n_pos = SPA_MIN(info->channels, SPA_N_ELEMENTS(info->position));
|
||||||
|
for (guint i = 0; i < n_pos; i++)
|
||||||
wp_spa_pod_builder_add_id (position_builder, info->position[i]);
|
wp_spa_pod_builder_add_id (position_builder, info->position[i]);
|
||||||
|
|
||||||
/* Add the position property */
|
/* Add the position property */
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue