cli: reject team.config from files with '\0'

The team-config must be valid utf-8. First of all, JSON
is also defined for other unicode encodings, but libjansson
can only handle utf-8. So, just require that.

A file with a '\0' truncates part of the file and is thus
invalid.
This commit is contained in:
Thomas Haller 2016-09-27 11:21:44 +02:00
parent c2ef5da42a
commit 1b8c201cce
2 changed files with 7 additions and 0 deletions

View file

@ -871,6 +871,12 @@ nmc_team_check_config (const char *config, char **out_config, GError **error)
return FALSE;
}
} else {
if (c_len != strlen (contents)) {
g_set_error (error, NMCLI_ERROR, NMC_RESULT_ERROR_USER_INPUT,
_("team config file '%s' contains non-valid utf-8"),
config);
return FALSE;
}
filename = config;
config = config_clone = g_steal_pointer (&contents);
}

View file

@ -1085,6 +1085,7 @@ global:
} libnm_1_2_0;
libnm_1_6_0 {
global:
nm_capability_get_type;
nm_utils_is_json_object;
} libnm_1_4_0;