summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2019-08-02 17:34:59 +0200
committerThomas Haller <thaller@redhat.com>2019-08-02 18:18:30 +0200
commit55143dad95dde9e5eae2a5084e39313fcfba4a4a (patch)
tree14249317668e53483dd46af852d193b2942fb303
parent9ed26de3daf71020dd0148fcc1ad9de8cc5e5009 (diff)
downloadNetworkManager-55143dad95dde9e5eae2a5084e39313fcfba4a4a.tar.gz
supplicant: don't put binary data in error message for supplicant
For better or worse, the API does not require the value to be a UTF-8 string. We cannot just concatenate binary to a string. Instead, backslash escape it with utf8safe-escape. Also, this will shut up a (wrong) coverity warning at this place.
-rw-r--r--src/supplicant/nm-supplicant-config.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/supplicant/nm-supplicant-config.c b/src/supplicant/nm-supplicant-config.c
index 806c087c8a..f6e3c7da53 100644
--- a/src/supplicant/nm-supplicant-config.c
+++ b/src/supplicant/nm-supplicant-config.c
@@ -139,11 +139,17 @@ nm_supplicant_config_add_option_with_type (NMSupplicantConfig *self,
else {
type = nm_supplicant_settings_verify_setting (key, value, len);
if (type == TYPE_INVALID) {
- char buf[255];
- memset (&buf[0], 0, sizeof (buf));
- memcpy (&buf[0], value, len > 254 ? 254 : len);
+ gs_free char *str_free = NULL;
+ const char *str;
+
+ str = nm_utils_buf_utf8safe_escape (value, len, NM_UTILS_STR_UTF8_SAFE_FLAG_ESCAPE_CTRL, &str_free);
+
+ str = nm_strquote_a (255, str);
+
g_set_error (error, NM_SUPPLICANT_ERROR, NM_SUPPLICANT_ERROR_CONFIG,
- "key '%s' and/or value '%s' invalid", key, hidden ?: buf);
+ "key '%s' and/or value %s invalid",
+ key,
+ hidden ?: str);
return FALSE;
}
}