]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
basic/env-util: don't relax unesaping of serialized environment strings 7061/head
authorLubomir Rintel <lkundrak@v3.sk>
Wed, 11 Oct 2017 13:05:38 +0000 (15:05 +0200)
committerLubomir Rintel <lkundrak@v3.sk>
Wed, 11 Oct 2017 13:05:38 +0000 (15:05 +0200)
We wrote them ourselves -- they shouldn't contain invalid sequences.

src/basic/env-util.c
src/test/test-env-util.c

index a8b51e719f21727f933c2dd7347765c8022329bb..0da10de0c884ae7b842e382cf7cf2189cd94072f 100644 (file)
@@ -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;
 
index b14d62760f609a77042f096ea1513dbaec5e6670..a76f691b79f619ea452bfcc0288ee11e6523c155 100644 (file)
@@ -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) {