summaryrefslogtreecommitdiff
path: root/src/test/test-util.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2014-07-02 13:42:25 +0200
committerLennart Poettering <lennart@poettering.net>2014-07-02 13:45:49 +0200
commite0a33e7ba619eb44f732aaf23cb249fa43d0ce8d (patch)
treedcd70f11ddc1382814ae10eb2f8586f3b637d5cf /src/test/test-util.c
parentfecc80c1ba2eed9dadb9a10c15508c356bcc5fc1 (diff)
util: when unescaping strings, don't allow smuggling in of additional NUL bytes
Better safe than sorry.
Diffstat (limited to 'src/test/test-util.c')
-rw-r--r--src/test/test-util.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/test/test-util.c b/src/test/test-util.c
index dbc7cfe397..44921bd156 100644
--- a/src/test/test-util.c
+++ b/src/test/test-util.c
@@ -297,14 +297,16 @@ static void test_undecchar(void) {
static void test_cescape(void) {
_cleanup_free_ char *escaped;
- escaped = cescape("abc\\\"\b\f\n\r\t\v\a\003\177\234\313");
+
+ assert_se(escaped = cescape("abc\\\"\b\f\n\r\t\v\a\003\177\234\313"));
assert_se(streq(escaped, "abc\\\\\\\"\\b\\f\\n\\r\\t\\v\\a\\003\\177\\234\\313"));
}
static void test_cunescape(void) {
_cleanup_free_ char *unescaped;
- unescaped = cunescape("abc\\\\\\\"\\b\\f\\a\\n\\r\\t\\v\\003\\177\\234\\313");
- assert_se(streq(unescaped, "abc\\\"\b\f\a\n\r\t\v\003\177\234\313"));
+
+ assert_se(unescaped = cunescape("abc\\\\\\\"\\b\\f\\a\\n\\r\\t\\v\\003\\177\\234\\313\\000\\x00"));
+ assert_se(streq(unescaped, "abc\\\"\b\f\a\n\r\t\v\003\177\234\313\\000\\x00"));
}
static void test_foreach_word(void) {