From 03abce72e53a9bdb3fa45558063452886034520f Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Wed, 1 Mar 2023 13:41:17 +0100 Subject: [PATCH] pulse-server: error on invalid format When an invalid format is given as a module argument, generate an error. --- src/modules/module-protocol-pulse/modules/module-null-sink.c | 4 ++++ src/modules/module-protocol-pulse/modules/module-pipe-sink.c | 5 +++++ .../module-protocol-pulse/modules/module-pipe-source.c | 5 +++++ 3 files changed, 14 insertions(+) diff --git a/src/modules/module-protocol-pulse/modules/module-null-sink.c b/src/modules/module-protocol-pulse/modules/module-null-sink.c index 96a27a248..b3fcd3715 100644 --- a/src/modules/module-protocol-pulse/modules/module-null-sink.c +++ b/src/modules/module-protocol-pulse/modules/module-null-sink.c @@ -166,6 +166,10 @@ static int module_null_sink_prepare(struct module * const module) info.format = module->impl->defs.sample_spec.format; if ((str = pw_properties_get(props, "format")) != NULL) { info.format = format_paname2id(str, strlen(str)); + if (info.format == SPA_AUDIO_FORMAT_UNKNOWN) { + pw_log_error("invalid format '%s'", str); + return -EINVAL; + } pw_properties_set(props, "format", NULL); } diff --git a/src/modules/module-protocol-pulse/modules/module-pipe-sink.c b/src/modules/module-protocol-pulse/modules/module-pipe-sink.c index 055a6c17a..beb7462c3 100644 --- a/src/modules/module-protocol-pulse/modules/module-pipe-sink.c +++ b/src/modules/module-protocol-pulse/modules/module-pipe-sink.c @@ -148,6 +148,11 @@ static int module_pipe_sink_prepare(struct module * const module) info.format = SPA_AUDIO_FORMAT_S16; if ((str = pw_properties_get(props, "format")) != NULL) { info.format = format_paname2id(str, strlen(str)); + if (info.format == SPA_AUDIO_FORMAT_UNKNOWN) { + pw_log_error("invalid format '%s'", str); + res = -EINVAL; + goto out; + } pw_properties_set(props, "format", NULL); } if ((str = pw_properties_get(props, "sink_name")) != NULL) { diff --git a/src/modules/module-protocol-pulse/modules/module-pipe-source.c b/src/modules/module-protocol-pulse/modules/module-pipe-source.c index 4af9fdd99..be3bbfd84 100644 --- a/src/modules/module-protocol-pulse/modules/module-pipe-source.c +++ b/src/modules/module-protocol-pulse/modules/module-pipe-source.c @@ -148,6 +148,11 @@ static int module_pipe_source_prepare(struct module * const module) info.format = SPA_AUDIO_FORMAT_S16; if ((str = pw_properties_get(props, "format")) != NULL) { info.format = format_paname2id(str, strlen(str)); + if (info.format == SPA_AUDIO_FORMAT_UNKNOWN) { + pw_log_error("invalid format '%s'", str); + res = -EINVAL; + goto out; + } pw_properties_set(props, "format", NULL); } if ((str = pw_properties_get(props, "source_name")) != NULL) {