|
Zbigniew Jędrzejewski-Szmek |
35bb94 |
From 1ff2852a188de9235a293a347683c4c012708fe8 Mon Sep 17 00:00:00 2001
|
|
Zbigniew Jędrzejewski-Szmek |
35bb94 |
From: Lubomir Rintel <lkundrak@v3.sk>
|
|
Zbigniew Jędrzejewski-Szmek |
35bb94 |
Date: Wed, 11 Oct 2017 15:05:38 +0200
|
|
Zbigniew Jędrzejewski-Szmek |
35bb94 |
Subject: [PATCH] basic/env-util: don't relax unesaping of serialized
|
|
Zbigniew Jędrzejewski-Szmek |
35bb94 |
environment strings
|
|
Zbigniew Jędrzejewski-Szmek |
35bb94 |
|
|
Zbigniew Jędrzejewski-Szmek |
35bb94 |
We wrote them ourselves -- they shouldn't contain invalid sequences.
|
|
Zbigniew Jędrzejewski-Szmek |
35bb94 |
|
|
Zbigniew Jędrzejewski-Szmek |
35bb94 |
(cherry picked from commit c7d797bbdfaccd950988698823e17103f418a3c5)
|
|
Zbigniew Jędrzejewski-Szmek |
35bb94 |
---
|
|
Zbigniew Jędrzejewski-Szmek |
35bb94 |
src/basic/env-util.c | 2 +-
|
|
Zbigniew Jędrzejewski-Szmek |
35bb94 |
src/test/test-env-util.c | 3 +++
|
|
Zbigniew Jędrzejewski-Szmek |
35bb94 |
2 files changed, 4 insertions(+), 1 deletion(-)
|
|
Zbigniew Jędrzejewski-Szmek |
35bb94 |
|
|
Zbigniew Jędrzejewski-Szmek |
35bb94 |
diff --git a/src/basic/env-util.c b/src/basic/env-util.c
|
|
Zbigniew Jędrzejewski-Szmek |
35bb94 |
index a8b51e719f..0da10de0c8 100644
|
|
Zbigniew Jędrzejewski-Szmek |
35bb94 |
--- a/src/basic/env-util.c
|
|
Zbigniew Jędrzejewski-Szmek |
35bb94 |
+++ b/src/basic/env-util.c
|
|
Zbigniew Jędrzejewski-Szmek |
35bb94 |
@@ -805,7 +805,7 @@ int deserialize_environment(char ***environment, const char *line) {
|
|
Zbigniew Jędrzejewski-Szmek |
35bb94 |
assert(environment);
|
|
Zbigniew Jędrzejewski-Szmek |
35bb94 |
|
|
Zbigniew Jędrzejewski-Szmek |
35bb94 |
assert(startswith(line, "env="));
|
|
Zbigniew Jędrzejewski-Szmek |
35bb94 |
- r = cunescape(line + 4, UNESCAPE_RELAX, &uce;;
|
|
Zbigniew Jędrzejewski-Szmek |
35bb94 |
+ r = cunescape(line + 4, 0, &uce;;
|
|
Zbigniew Jędrzejewski-Szmek |
35bb94 |
if (r < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
35bb94 |
return r;
|
|
Zbigniew Jędrzejewski-Szmek |
35bb94 |
|
|
Zbigniew Jędrzejewski-Szmek |
35bb94 |
diff --git a/src/test/test-env-util.c b/src/test/test-env-util.c
|
|
Zbigniew Jędrzejewski-Szmek |
35bb94 |
index b14d62760f..a76f691b79 100644
|
|
Zbigniew Jędrzejewski-Szmek |
35bb94 |
--- a/src/test/test-env-util.c
|
|
Zbigniew Jędrzejewski-Szmek |
35bb94 |
+++ b/src/test/test-env-util.c
|
|
Zbigniew Jędrzejewski-Szmek |
35bb94 |
@@ -323,6 +323,9 @@ static void test_deserialize_environment(void) {
|
|
Zbigniew Jędrzejewski-Szmek |
35bb94 |
assert_se(deserialize_environment(&env, "env=FOO%%=a\\177b\\nc\\td e") >= 0);
|
|
Zbigniew Jędrzejewski-Szmek |
35bb94 |
|
|
Zbigniew Jędrzejewski-Szmek |
35bb94 |
assert_se(strv_equal(env, STRV_MAKE("A=1", "B=2", "FOO%%=a\177b\nc\td e")));
|
|
Zbigniew Jędrzejewski-Szmek |
35bb94 |
+
|
|
Zbigniew Jędrzejewski-Szmek |
35bb94 |
+ assert_se(deserialize_environment(&env, "env=foo\\") < 0);
|
|
Zbigniew Jędrzejewski-Szmek |
35bb94 |
+ assert_se(deserialize_environment(&env, "env=bar\\_baz") < 0);
|
|
Zbigniew Jędrzejewski-Szmek |
35bb94 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
35bb94 |
|
|
Zbigniew Jędrzejewski-Szmek |
35bb94 |
static void test_serialize_environment(void) {
|