[pulseaudio-discuss] [PATCH] alsa-util: don't crash on devices with more than 32 channels

Takashi Sakamoto o-takashi at sakamocchi.jp
Sun Jan 29 01:36:34 UTC 2017


On Jan 29 2017 01:08, Tanu Kaskinen wrote:
> The pa_channel_map_init_extend() call later in the function crashes if
> if ss->channels is greater than PA_CHANNELS_MAX.
>
> Reported here:
> https://lists.freedesktop.org/archives/pulseaudio-discuss/2017-January/027404.html
> ---
>  src/modules/alsa/alsa-util.c | 7 +++++++
>  1 file changed, 7 insertions(+)

Reviewed-by: Takashi Sakamoto <o-takashi at sakamocchi.jp>
Tested-by: Takashi Sakamoto <o-takashi at sakamocchi.jp>

I tested with a device which has 34ch capture and 30ch playback. 
PulseAudio adds a sink for the playback PCM substream with multichannel 
profile, and ignores the capture PCM substream.

But I think there's a space to discuss this issue more. In this world, 
we have some devices with over-32ch, or users can add virtual sound card 
with over-32ch. Although such users seem to work without PulseAudio, 
it's better to drop this kind of restriction for better future of this 
sound server.

> diff --git a/src/modules/alsa/alsa-util.c b/src/modules/alsa/alsa-util.c
> index 63d370f52..61fb4903c 100644
> --- a/src/modules/alsa/alsa-util.c
> +++ b/src/modules/alsa/alsa-util.c
> @@ -747,6 +747,13 @@ snd_pcm_t *pa_alsa_open_by_device_string(
>              goto fail;
>          }
>
> +        if (ss->channels > PA_CHANNELS_MAX) {
> +            pa_log("Device %s has %u channels, but PulseAudio supports only %u channels. Unable to use the device.",
> +                   d, ss->channels, PA_CHANNELS_MAX);
> +            snd_pcm_close(pcm_handle);
> +            goto fail;
> +        }
> +
>          if (dev)
>              *dev = d;
>          else


Regards

Takashi Sakamoto


More information about the pulseaudio-discuss mailing list