summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJiří Klimeš <jklimes@redhat.com>2015-11-27 21:58:05 +0100
committerJiří Klimeš <jklimes@redhat.com>2015-11-28 19:56:27 +0100
commit717b494a007891e8ccdd796dbd45fa9b435fec8d (patch)
tree79c7da5344da9ca64798b782e46dff39e4f9d567
parent00bfaa4ed7c45e7fa532cd21e73139a95eac41ed (diff)
downloadNetworkManager-717b494a007891e8ccdd796dbd45fa9b435fec8d.tar.gz
cli: fix an error in setting s390-options in nmcli editor
nmcli> set eth.s390-options portno= (process:4711): libnm-CRITICAL **: nm_setting_wired_add_s390_option: assertion 'value_len > 0 && value_len < 200' failed (cherry picked from commit 6ffe4b61f7efebca79f8a13d75f7499f8ef65f72)
-rw-r--r--clients/cli/settings.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/clients/cli/settings.c b/clients/cli/settings.c
index 7871055968..597cc881fb 100644
--- a/clients/cli/settings.c
+++ b/clients/cli/settings.c
@@ -4286,12 +4286,23 @@ nmc_property_wired_set_s390_nettype (NMSetting *setting, const char *prop, const
DEFINE_ALLOWED_VAL_FUNC (nmc_property_wired_allowed_s390_nettype, wired_valid_s390_nettypes)
/* 's390-options' */
+/* Validate value of 's390-options' */
+static const char *
+_validate_s390_option_value (const char *option, const char *value, GError **error)
+{
+ /* nm_setting_wired_add_s390_option() requires value len in <1,199> interval */
+ if (!value || !*value || strlen (value) >= 200) {
+ g_set_error (error, 1, 0, _("'%s' string value should consists of 1 - 199 characters"), option);
+ return NULL;
+ }
+ return value;
+}
DEFINE_SETTER_OPTIONS (nmc_property_wired_set_s390_options,
NM_SETTING_WIRED,
NMSettingWired,
nm_setting_wired_add_s390_option,
nm_setting_wired_get_valid_s390_options,
- NULL)
+ _validate_s390_option_value)
DEFINE_REMOVER_OPTION (nmc_property_wired_remove_option_s390_options,
NM_SETTING_WIRED,
nm_setting_wired_remove_s390_option)