From 6ffe4b61f7efebca79f8a13d75f7499f8ef65f72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Klime=C5=A1?= Date: Fri, 27 Nov 2015 21:58:05 +0100 Subject: [PATCH] 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 --- clients/cli/settings.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/clients/cli/settings.c b/clients/cli/settings.c index d91959196..19eeaf85b 100644 --- a/clients/cli/settings.c +++ b/clients/cli/settings.c @@ -4559,12 +4559,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)