diff options
author | Jiří Klimeš <jklimes@redhat.com> | 2014-03-05 13:59:17 +0100 |
---|---|---|
committer | Jiří Klimeš <jklimes@redhat.com> | 2014-03-05 14:07:57 +0100 |
commit | 6961e9b71f8e773306693f73a5029242da2ac56d (patch) | |
tree | 39c2a9d8bf67e7b4beceb8f2c99a4b73428a9149 | |
parent | d2ed33e4cd0ca405317de647cc6c3887fa6a74fd (diff) | |
download | NetworkManager-jk/team-port-config.tar.gz |
cli: sanitize team config before setting it into propertyjk/team-port-config
Replace '\r' and '\n' chareacter with a space in the configuration.
libteamdctl sends the config to team daemon using its usock interface that
separates parameters with '\n'.
Related: rh #1051517
-rw-r--r-- | cli/src/common.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/cli/src/common.c b/cli/src/common.c index 6f6d0c0838..2dd59bdbcb 100644 --- a/cli/src/common.c +++ b/cli/src/common.c @@ -907,6 +907,17 @@ nmc_bond_validate_mode (const char *mode, GError **error) return nmc_string_is_valid (mode, valid_modes, error); } +/* + * nmc_team_check_config: + * @config: file name with team config, or raw team JSON config data + * @out_config: raw team JSON config data (with removed new-line characters) + * @error: location to store error, or %NUL + * + * Check team config from @config parameter and return the checked/sanitized + * config in @out_config. + * + * Returns: %TRUE if the config is valid, %FALSE if it is invalid + */ gboolean nmc_team_check_config (const char *config, char **out_config, GError **error) { @@ -936,7 +947,7 @@ nmc_team_check_config (const char *config, char **out_config, GError **error) g_free (contents); return FALSE; } - *out_config = contents; + *out_config = g_strdelimit (contents, "\r\n", ' '); return TRUE; } |