diff options
author | Thomas Haller <thaller@redhat.com> | 2017-11-20 15:30:36 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2017-11-20 15:39:48 +0100 |
commit | 89c89143b5ace4cff4a6fba9359259a010781284 (patch) | |
tree | 497673e67080b9793234c785e85468e2759c099b | |
parent | 97f8d2167437e573531e0575741e279fd7e32ffd (diff) | |
download | NetworkManager-89c89143b5ace4cff4a6fba9359259a010781284.tar.gz |
keyfile: fix escaping ascii control characters in nm_keyfile_key_encode()
Matters when backslash escaping ascii charaters <= 0xF, to
produce "\\XX" instead of "\\ X". For example tabulator is "\\09".
This also can trigger an nm_assert() failure, when building with
--with-more-asserts=5 (or higher).
-rw-r--r-- | libnm-core/nm-keyfile-utils.c | 2 | ||||
-rw-r--r-- | libnm-core/tests/test-keyfile.c | 5 |
2 files changed, 6 insertions, 1 deletions
diff --git a/libnm-core/nm-keyfile-utils.c b/libnm-core/nm-keyfile-utils.c index 1b7860d873..8858331949 100644 --- a/libnm-core/nm-keyfile-utils.c +++ b/libnm-core/nm-keyfile-utils.c @@ -442,7 +442,7 @@ _keyfile_key_encode (const char *name, && g_ascii_isxdigit (name[i + 2])) || ( ch == ' ' && name[i + 1] == '\0')) - g_string_append_printf (str, "\\%2X", ch); + g_string_append_printf (str, "\\%02X", ch); else g_string_append_c (str, (char) ch); } diff --git a/libnm-core/tests/test-keyfile.c b/libnm-core/tests/test-keyfile.c index 6f3b0e3276..c7d638244d 100644 --- a/libnm-core/tests/test-keyfile.c +++ b/libnm-core/tests/test-keyfile.c @@ -99,6 +99,11 @@ test_encode_key (void) do_test_encode_key_bijection (kf, " ", "\\20 \\20"); do_test_encode_key_decode_surjection (kf, "f\\20c", "f c"); do_test_encode_key_decode_surjection (kf, "\\20\\20\\20", "\\20 \\20"); + + do_test_encode_key_bijection (kf, "\t", "\\09"); + do_test_encode_key_bijection (kf, "\t=x", "\\09\\3Dx"); + do_test_encode_key_bijection (kf, "(nm-openvpn-auth-dialog:10283): GdkPixbuf-DEBUG: \tCopy pixels == false", + "(nm-openvpn-auth-dialog:10283): GdkPixbuf-DEBUG: \\09Copy pixels \\3D\\3D false"); } /*****************************************************************************/ |