security: limit blocklist regex length in switch-on-connect module

A PulseAudio client can load this module with an arbitrarily complex
blocklist regex, causing catastrophic backtracking in regexec on
every new device. Cap the regex string at 1024 characters.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Wim Taymans 2026-04-30 17:40:25 +02:00
parent a585b117da
commit 92a174ff1e

View file

@ -257,6 +257,9 @@ static int module_switch_on_connect_prepare(struct module * const module)
if ((str = pw_properties_get(props, "blocklist")) == NULL) if ((str = pw_properties_get(props, "blocklist")) == NULL)
str = DEFAULT_BLOCKLIST; str = DEFAULT_BLOCKLIST;
if (strlen(str) > 1024)
return -EINVAL;
if (regcomp(&d->blocklist, str, REG_NOSUB | REG_EXTENDED) != 0) if (regcomp(&d->blocklist, str, REG_NOSUB | REG_EXTENDED) != 0)
return -EINVAL; return -EINVAL;