diff options
author | Arun Raghavan <arun.raghavan@collabora.co.uk> | 2010-10-09 23:10:00 +0530 |
---|---|---|
committer | Arun Raghavan <arun.raghavan@collabora.co.uk> | 2010-10-15 01:10:00 +0530 |
commit | 0edbb2c6aa28faf564d2929318ab21c872335f04 (patch) | |
tree | f646946f1ba99620aa3aa5cef22e50bf707b797c /src/pulsecore/cli-command.c | |
parent | 49101fc540aec9a249e97a9f650be38f9f92f5ac (diff) |
cli: Validate volume before setting
This causes an error to be generated if an invalid volume is provided to
commands that set sink/sink-input/source volume.
Diffstat (limited to 'src/pulsecore/cli-command.c')
-rw-r--r-- | src/pulsecore/cli-command.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/pulsecore/cli-command.c b/src/pulsecore/cli-command.c index d23331d9..a18ebd33 100644 --- a/src/pulsecore/cli-command.c +++ b/src/pulsecore/cli-command.c @@ -527,6 +527,11 @@ static int pa_cli_command_sink_volume(pa_core *c, pa_tokenizer *t, pa_strbuf *bu return -1; } + if (!PA_VOLUME_IS_VALID(volume)) { + pa_strbuf_puts(buf, "Volume outside permissible range.\n"); + return -1; + } + if (!(sink = pa_namereg_get(c, n, PA_NAMEREG_SINK))) { pa_strbuf_puts(buf, "No sink found by this name or index.\n"); return -1; @@ -569,6 +574,11 @@ static int pa_cli_command_sink_input_volume(pa_core *c, pa_tokenizer *t, pa_strb return -1; } + if (!PA_VOLUME_IS_VALID(volume)) { + pa_strbuf_puts(buf, "Volume outside permissible range.\n"); + return -1; + } + if (!(si = pa_idxset_get_by_index(c->sink_inputs, (uint32_t) idx))) { pa_strbuf_puts(buf, "No sink input found with this index.\n"); return -1; @@ -605,6 +615,11 @@ static int pa_cli_command_source_volume(pa_core *c, pa_tokenizer *t, pa_strbuf * return -1; } + if (!PA_VOLUME_IS_VALID(volume)) { + pa_strbuf_puts(buf, "Volume outside permissible range.\n"); + return -1; + } + if (!(source = pa_namereg_get(c, n, PA_NAMEREG_SOURCE))) { pa_strbuf_puts(buf, "No source found by this name or index.\n"); return -1; |