summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2014-03-14 16:43:19 +0100
committerThomas Haller <thaller@redhat.com>2014-03-14 16:55:51 +0100
commit2f67105a914b234562e69717f8a05e9db3239eb3 (patch)
tree2dc37d526e6adc2ec9226d6037d27c8a5fcd050c
parent45a326d9c70f3b7235f6749186a6509de113ea72 (diff)
downloadNetworkManager-2f67105a914b234562e69717f8a05e9db3239eb3.tar.gz
libnm-util: remove assert to nm_utils_ip4_netmask_to_prefix
Commit 240c92ddb55c3ae61fa7c4768088eb44b3905a82 added an assert to check that the input netmask is valid. Revert that commit for the most part, some changes to the test function are not reverted. We don't want to assert for a valid netmask, because it's common to read the netmask from (untrusted) user input, so we don't want to assert against it. The caller *could* validate the netmask from untrusted sources, but with the assert in place it cannot validate it in the most obvious way: prefix = nm_utils_ip4_netmask_to_prefix (netmask); if (netmask != nm_utils_ip4_prefix_to_netmask (prefix)) goto fail; Signed-off-by: Thomas Haller <thaller@redhat.com>
-rw-r--r--libnm-util/nm-utils.c5
-rw-r--r--libnm-util/tests/test-general.c5
2 files changed, 0 insertions, 10 deletions
diff --git a/libnm-util/nm-utils.c b/libnm-util/nm-utils.c
index 4047973b5d..aead8e3e6c 100644
--- a/libnm-util/nm-utils.c
+++ b/libnm-util/nm-utils.c
@@ -1084,11 +1084,6 @@ nm_utils_ip4_netmask_to_prefix (guint32 netmask)
v <<= 1;
}
- /* Assert that caller provided a valid netmask, without "holes" and all the
- * first @prefix bits set.
- **/
- g_return_val_if_fail (netmask == nm_utils_ip4_prefix_to_netmask (prefix), prefix);
-
return prefix;
}
diff --git a/libnm-util/tests/test-general.c b/libnm-util/tests/test-general.c
index 79206695c5..097e238fa6 100644
--- a/libnm-util/tests/test-general.c
+++ b/libnm-util/tests/test-general.c
@@ -1780,16 +1780,11 @@ test_ip4_netmask_to_prefix (void)
if (netmask_holey == netmask)
continue;
- (void) prefix_holey;
-#if GLIB_CHECK_VERSION(2,34,0)
/* create an invalid netmask with holes and check that the function
* returns the longest prefix and logs an assert. */
- g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, "nm_utils_ip4_netmask_to_prefix: assertion 'netmask == nm_utils_ip4_prefix_to_netmask (prefix)' failed");
prefix_holey = nm_utils_ip4_netmask_to_prefix (netmask_holey);
- g_test_assert_expected_messages ();
g_assert_cmpint (i, ==, prefix_holey);
-#endif
}
}