summary refs log tree commit diff
path: root/libnm-core
diff options
context:
space:
mode:
Diffstat (limited to 'libnm-core')
-rw-r--r--libnm-core/nm-setting-bond.c25
-rw-r--r--libnm-core/nm-utils.c2
-rw-r--r--libnm-core/tests/test-general.c6
-rw-r--r--libnm-core/tests/test-setting.c9
4 files changed, 34 insertions, 8 deletions
diff --git a/libnm-core/nm-setting-bond.c b/libnm-core/nm-setting-bond.c
index f4c35663..f3ae9ef5 100644
--- a/libnm-core/nm-setting-bond.c
+++ b/libnm-core/nm-setting-bond.c
@@ -92,6 +92,16 @@ static const BondDefault defaults[] = {
 
 /*****************************************************************************/
 
+static int
+_atoi (const char *value)
+{
+	int v;
+
+	v = _nm_utils_ascii_str_to_int64 (value, 10, 0, G_MAXINT, -1);
+	nm_assert (v >= 0);
+	return v;
+};
+
 /**
  * nm_setting_bond_get_num_options:
  * @setting: the #NMSettingBond
@@ -647,21 +657,26 @@ verify (NMSetting *setting, NMConnection *connection, GError **error)
 	}
 
 	if (miimon == 0) {
-		/* updelay and downdelay can only be used with miimon */
-		if (g_hash_table_lookup (priv->options, NM_SETTING_BOND_OPTION_UPDELAY)) {
+		gpointer delayopt;
+
+		/* updelay and downdelay need miimon to be enabled to be valid */
+		delayopt = g_hash_table_lookup (priv->options, NM_SETTING_BOND_OPTION_UPDELAY);
+		if (delayopt && _atoi (delayopt) > 0) {
 			g_set_error (error,
 			             NM_CONNECTION_ERROR,
 			             NM_CONNECTION_ERROR_INVALID_PROPERTY,
-			             _("'%s' option requires '%s' option to be set"),
+			             _("'%s' option requires '%s' option to be enabled"),
 			             NM_SETTING_BOND_OPTION_UPDELAY, NM_SETTING_BOND_OPTION_MIIMON);
 			g_prefix_error (error, "%s.%s: ", NM_SETTING_BOND_SETTING_NAME, NM_SETTING_BOND_OPTIONS);
 			return FALSE;
 		}
-		if (g_hash_table_lookup (priv->options, NM_SETTING_BOND_OPTION_DOWNDELAY)) {
+
+		delayopt = g_hash_table_lookup (priv->options, NM_SETTING_BOND_OPTION_DOWNDELAY);
+		if (delayopt && _atoi (delayopt) > 0) {
 			g_set_error (error,
 			             NM_CONNECTION_ERROR,
 			             NM_CONNECTION_ERROR_INVALID_PROPERTY,
-			             _("'%s' option requires '%s' option to be set"),
+			             _("'%s' option requires '%s' option to be enabled"),
 			             NM_SETTING_BOND_OPTION_DOWNDELAY, NM_SETTING_BOND_OPTION_MIIMON);
 			g_prefix_error (error, "%s.%s: ", NM_SETTING_BOND_SETTING_NAME, NM_SETTING_BOND_OPTIONS);
 			return FALSE;
diff --git a/libnm-core/nm-utils.c b/libnm-core/nm-utils.c
index 90ae4070..ea4c52c0 100644
--- a/libnm-core/nm-utils.c
+++ b/libnm-core/nm-utils.c
@@ -1185,7 +1185,7 @@ nm_utils_security_valid (NMUtilsSecurityType type,
 	case NMU_SEC_LEAP: /* require PRIVACY bit for LEAP? */
 		if (adhoc)
 			return FALSE;
-		/* fall through */
+		/* fall-through */
 	case NMU_SEC_STATIC_WEP:
 		g_assert (have_ap);
 		if (!(ap_flags & NM_802_11_AP_FLAGS_PRIVACY))
diff --git a/libnm-core/tests/test-general.c b/libnm-core/tests/test-general.c
index 3b75e0f7..0ccdd5d2 100644
--- a/libnm-core/tests/test-general.c
+++ b/libnm-core/tests/test-general.c
@@ -7761,7 +7761,7 @@ test_nm_in_set (void)
 	_ASSERT (5,  NM_IN_SET_SE (-1, G( 1), G( 2), G( 3), G(-1), G( 5)));
 	_ASSERT (6,  NM_IN_SET_SE (-1, G( 1), G( 2), G( 3), G( 4), G( 5), G(-1)));
 
-	(void) NM_IN_SET ("a",  "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16");
+	g_assert (!NM_IN_SET (0,  1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16));
 #undef G
 #undef N
 #undef _ASSERT
@@ -7888,7 +7888,9 @@ test_nm_in_strset (void)
 	_ASSERT (6,  NM_IN_STRSET ("a",  G(NULL), G("b"),  G("c"),  G("d"),  G("e"),  G("a")));
 	_ASSERT (6, !NM_IN_STRSET ("a",  G(NULL), G("b"),  G("c"),  G("d"),  G("e"),  G("f")));
 
-	(void) NM_IN_STRSET ("a",  "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16");
+	g_assert (!NM_IN_STRSET (NULL,  "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16"));
+	g_assert (!NM_IN_STRSET ("_",   "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16"));
+	g_assert ( NM_IN_STRSET ("10",  "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16"));
 #undef G
 #undef N
 #undef _ASSERT
diff --git a/libnm-core/tests/test-setting.c b/libnm-core/tests/test-setting.c
index 40852277..5b2c7077 100644
--- a/libnm-core/tests/test-setting.c
+++ b/libnm-core/tests/test-setting.c
@@ -586,6 +586,15 @@ test_bond_verify (void)
 	test_verify_options (TRUE,
 	                     "mode", "802.3ad",
 	                     "ad_actor_system", "ae:00:11:33:44:55");
+	test_verify_options (TRUE,
+	                     "mode", "0",
+	                     "miimon", "0",
+	                     "updelay", "0",
+	                     "downdelay", "0");
+	test_verify_options (TRUE,
+	                     "mode", "0",
+	                     "downdelay", "0",
+	                     "updelay", "0");
 }
 
 static void