From ca6c3f80f50f3b1d1f33c7700dbc60652c1b8aed Mon Sep 17 00:00:00 2001 From: Tanu Kaskinen Date: Sat, 28 Jan 2017 18:08:24 +0200 Subject: [PATCH] alsa-util: don't crash on devices with more than 32 channels 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 Reviewed-by: Takashi Sakamoto Tested-by: Takashi Sakamoto --- src/modules/alsa/alsa-util.c | 7 +++++++ 1 file changed, 7 insertions(+) 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