From 123b964a537c21e9ebaf849acefb23f0f13db785 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 11 Feb 2013 23:41:15 +0100 Subject: manager: validate environment parameters for SetEnvironment(), UnsetEnvironment() bus calls --- src/shared/env-util.c | 15 +++++++++++++++ src/shared/env-util.h | 2 ++ 2 files changed, 17 insertions(+) (limited to 'src/shared') diff --git a/src/shared/env-util.c b/src/shared/env-util.c index 7a213a77c0..9a833d22e4 100644 --- a/src/shared/env-util.c +++ b/src/shared/env-util.c @@ -135,6 +135,21 @@ bool strv_env_is_valid(char **e) { return true; } +bool strv_env_name_or_assignment_is_valid(char **l) { + char **p, **q; + + STRV_FOREACH(p, l) { + if (!env_assignment_is_valid(*p) && !env_name_is_valid(*p)) + return false; + + STRV_FOREACH(q, p + 1) + if (streq(*p, *q)) + return false; + } + + return true; +} + static int env_append(char **r, char ***k, char **a) { assert(r); assert(k); diff --git a/src/shared/env-util.h b/src/shared/env-util.h index 93bf596ca8..9449576b5c 100644 --- a/src/shared/env-util.h +++ b/src/shared/env-util.h @@ -31,6 +31,8 @@ bool env_assignment_is_valid(const char *e); bool strv_env_is_valid(char **e); char **strv_env_clean(char **l); +bool strv_env_name_or_assignment_is_valid(char **l); + char **strv_env_merge(unsigned n_lists, ...); char **strv_env_delete(char **x, unsigned n_lists, ...); /* New copy */ -- cgit v1.2.3-54-g00ecf