summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTanu Kaskinen <tanuk@iki.fi>2012-06-13 11:15:03 +0300
committerTanu Kaskinen <tanuk@iki.fi>2013-03-29 16:45:49 +0200
commitbb080ab229660d03ebfa27adb501ac45a7a794be (patch)
tree031711ef26c4f5a492eb495d54d9cc6af7f1755f
parent300a43a1070cc41d691c8d14cbb3260abdfeb6f9 (diff)
core-util: Don't accept random words in pa_parse_boolean()
The old code accepted any word that started with "y", "Y", "n", "N", "t", "T", "f" or "F". Fix this by having a whitelist of full strings instead of checking just the first letter.
-rw-r--r--src/pulsecore/core-util.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/pulsecore/core-util.c b/src/pulsecore/core-util.c
index 1f4fca1e..4fa49442 100644
--- a/src/pulsecore/core-util.c
+++ b/src/pulsecore/core-util.c
@@ -937,9 +937,11 @@ int pa_parse_boolean(const char *v) {
pa_assert(v);
/* First we check language independent */
- if (pa_streq(v, "1") || v[0] == 'y' || v[0] == 'Y' || v[0] == 't' || v[0] == 'T' || !strcasecmp(v, "on"))
+ if (pa_streq(v, "1") || !strcasecmp(v, "y") || !strcasecmp(v, "t")
+ || !strcasecmp(v, "yes") || !strcasecmp(v, "true") || !strcasecmp(v, "on"))
return 1;
- else if (pa_streq(v, "0") || v[0] == 'n' || v[0] == 'N' || v[0] == 'f' || v[0] == 'F' || !strcasecmp(v, "off"))
+ else if (pa_streq(v, "0") || !strcasecmp(v, "n") || !strcasecmp(v, "f")
+ || !strcasecmp(v, "no") || !strcasecmp(v, "false") || !strcasecmp(v, "off"))
return 0;
#ifdef HAVE_LANGINFO_H