diff options
author | Lubomir Rintel <lkundrak@v3.sk> | 2017-10-11 15:05:38 +0200 |
---|---|---|
committer | Lubomir Rintel <lkundrak@v3.sk> | 2017-10-11 15:05:38 +0200 |
commit | c7d797bbdfaccd950988698823e17103f418a3c5 (patch) | |
tree | b963ae370090a825bc1561c857ae78bec41dcc5c | |
parent | ea43bdd1d7c14e3695a4cc081e4ef4f964160dc1 (diff) | |
download | systemd-c7d797bbdfaccd950988698823e17103f418a3c5.tar.gz |
basic/env-util: don't relax unesaping of serialized environment strings
We wrote them ourselves -- they shouldn't contain invalid sequences.
-rw-r--r-- | src/basic/env-util.c | 2 | ||||
-rw-r--r-- | src/test/test-env-util.c | 3 |
2 files changed, 4 insertions, 1 deletions
diff --git a/src/basic/env-util.c b/src/basic/env-util.c index a8b51e719f..0da10de0c8 100644 --- a/src/basic/env-util.c +++ b/src/basic/env-util.c @@ -805,7 +805,7 @@ int deserialize_environment(char ***environment, const char *line) { assert(environment); assert(startswith(line, "env=")); - r = cunescape(line + 4, UNESCAPE_RELAX, &uce); + r = cunescape(line + 4, 0, &uce); if (r < 0) return r; diff --git a/src/test/test-env-util.c b/src/test/test-env-util.c index b14d62760f..a76f691b79 100644 --- a/src/test/test-env-util.c +++ b/src/test/test-env-util.c @@ -323,6 +323,9 @@ static void test_deserialize_environment(void) { assert_se(deserialize_environment(&env, "env=FOO%%=a\\177b\\nc\\td e") >= 0); assert_se(strv_equal(env, STRV_MAKE("A=1", "B=2", "FOO%%=a\177b\nc\td e"))); + + assert_se(deserialize_environment(&env, "env=foo\\") < 0); + assert_se(deserialize_environment(&env, "env=bar\\_baz") < 0); } static void test_serialize_environment(void) { |