From e9c13e25b7c6a09ecf4fcd0f95a097e3242fbeb1 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 13 Jun 2008 21:07:21 +0000 Subject: consider passing the same argument twice to a module an error, also consider a variable name without following = an error git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@2525 fefdeb5f-60dc-0310-8127-8f9354f1896f --- src/pulsecore/modargs.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'src/pulsecore/modargs.c') diff --git a/src/pulsecore/modargs.c b/src/pulsecore/modargs.c index 0dab254b..489311e8 100644 --- a/src/pulsecore/modargs.c +++ b/src/pulsecore/modargs.c @@ -53,6 +53,12 @@ static int add_key_value(pa_hashmap *map, char *key, char *value, const char* co pa_assert(key); pa_assert(value); + if (pa_hashmap_get(map, key)) { + pa_xfree(key); + pa_xfree(value); + return -1; + } + if (valid_keys) { const char*const* v; for (v = valid_keys; *v; v++) @@ -80,7 +86,15 @@ pa_modargs *pa_modargs_new(const char *args, const char* const* valid_keys) { map = pa_hashmap_new(pa_idxset_string_hash_func, pa_idxset_string_compare_func); if (args) { - enum { WHITESPACE, KEY, VALUE_START, VALUE_SIMPLE, VALUE_DOUBLE_QUOTES, VALUE_TICKS } state; + enum { + WHITESPACE, + KEY, + VALUE_START, + VALUE_SIMPLE, + VALUE_DOUBLE_QUOTES, + VALUE_TICKS + } state; + const char *p, *key, *value; size_t key_len = 0, value_len = 0; @@ -100,6 +114,8 @@ pa_modargs *pa_modargs_new(const char *args, const char* const* valid_keys) { case KEY: if (*p == '=') state = VALUE_START; + else if (isspace(*p)) + goto fail; else key_len++; break; -- cgit