mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-26 01:50:08 +01:00
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.
(cherry picked from commit 55143dad95)
This commit is contained in:
parent
d99925a1b0
commit
da933ffe2a
1 changed files with 10 additions and 4 deletions
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue