summaryrefslogtreecommitdiff
path: root/src/utils
diff options
context:
space:
mode:
authorTanu Kaskinen <tanu.kaskinen@digia.com>2012-03-29 15:24:02 +0300
committerTanu Kaskinen <tanuk@iki.fi>2012-12-19 12:31:50 +0200
commit19c058dd083d2f0f2e73e82dc9b7d82952199045 (patch)
tree52446e059506691b4c51d05324773bbfd51b532a /src/utils
parent188d037150feb29ce31438b1b258c6b2117f688e (diff)
Fix pa_parse_boolean() return value checking.
pa_parse_boolean() return value shouldn't be stored in pa_bool_t, because 1 and -1 need to be distinguished.
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/pactl.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/utils/pactl.c b/src/utils/pactl.c
index e15520c7c..8d1d947ab 100644
--- a/src/utils/pactl.c
+++ b/src/utils/pactl.c
@@ -1622,6 +1622,8 @@ int main(int argc, char *argv[]) {
module_name = argv[optind + 1];
} else if (pa_streq(argv[optind], "suspend-sink")) {
+ int b;
+
action = SUSPEND_SINK;
if (argc > optind+3 || optind+1 >= argc) {
@@ -1629,12 +1631,19 @@ int main(int argc, char *argv[]) {
goto quit;
}
- suspend = pa_parse_boolean(argv[argc-1]);
+ if ((b = pa_parse_boolean(argv[argc-1])) < 0) {
+ pa_log(_("Invalid suspend specification."));
+ goto quit;
+ }
+
+ suspend = !!b;
if (argc > optind+2)
sink_name = pa_xstrdup(argv[optind+1]);
} else if (pa_streq(argv[optind], "suspend-source")) {
+ int b;
+
action = SUSPEND_SOURCE;
if (argc > optind+3 || optind+1 >= argc) {
@@ -1642,7 +1651,12 @@ int main(int argc, char *argv[]) {
goto quit;
}
- suspend = pa_parse_boolean(argv[argc-1]);
+ if ((b = pa_parse_boolean(argv[argc-1])) < 0) {
+ pa_log(_("Invalid suspend specification."));
+ goto quit;
+ }
+
+ suspend = !!b;
if (argc > optind+2)
source_name = pa_xstrdup(argv[optind+1]);