summary refs log tree commit diff
path: root/clients/cli/settings.c
diff options
context:
space:
mode:
Diffstat (limited to 'clients/cli/settings.c')
-rw-r--r--clients/cli/settings.c30
1 files changed, 27 insertions, 3 deletions
diff --git a/clients/cli/settings.c b/clients/cli/settings.c
index 8a6b5fa8..6a3c90c2 100644
--- a/clients/cli/settings.c
+++ b/clients/cli/settings.c
@@ -4150,13 +4150,26 @@ nmc_property_vlan_remove_egress_priority_map (NMSetting *setting,
 }
 
 /* --- NM_SETTING_VPN_SETTING_NAME property setter functions --- */
+/* Validate value of vpn 'data' and 'secret'  options */
+static const char *
+_validate_vpn_hash_value (const char *option, const char *value, GError **error)
+{
+	/* nm_setting_vpn_add_data_item() and nm_setting_vpn_add_secret() does not
+	 * allow empty strings */
+	if (!value || !*value) {
+		g_set_error (error, 1, 0, _("'%s' cannot be empty"), option);
+		return NULL;
+	}
+	return value;
+}
+
 /* 'data' */
 DEFINE_SETTER_OPTIONS (nmc_property_vpn_set_data,
                        NM_SETTING_VPN,
                        NMSettingVpn,
                        nm_setting_vpn_add_data_item,
                        NULL,
-                       NULL)
+                       _validate_vpn_hash_value)
 DEFINE_REMOVER_OPTION (nmc_property_vpn_remove_option_data,
                        NM_SETTING_VPN,
                        nm_setting_vpn_remove_data_item)
@@ -4167,7 +4180,7 @@ DEFINE_SETTER_OPTIONS (nmc_property_vpn_set_secrets,
                        NMSettingVpn,
                        nm_setting_vpn_add_secret,
                        NULL,
-                       NULL)
+                       _validate_vpn_hash_value)
 DEFINE_REMOVER_OPTION (nmc_property_vpn_remove_option_secret,
                        NM_SETTING_VPN,
                        nm_setting_vpn_remove_secret)
@@ -4273,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 consist 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)