From 39b2d78ee3f197652ee5d6a6773e81372a62bd74 Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Tue, 5 Jul 2011 19:26:43 -0500 Subject: libnm-util: enforce IPv4 prefix range validity Prefixes are between 1 and 32 inclusive so we might as well enforce that. --- libnm-util/nm-setting-ip4-config.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'libnm-util/nm-setting-ip4-config.c') diff --git a/libnm-util/nm-setting-ip4-config.c b/libnm-util/nm-setting-ip4-config.c index a632c4212c..6b164ea88a 100644 --- a/libnm-util/nm-setting-ip4-config.c +++ b/libnm-util/nm-setting-ip4-config.c @@ -1423,7 +1423,7 @@ nm_ip4_address_get_prefix (NMIP4Address *address) /** * nm_ip4_address_set_prefix: * @address: the #NMIP4Address - * @prefix: the address prefix, a number between 0 and 32 inclusive + * @prefix: the address prefix, a number between 1 and 32 inclusive * * Sets the IPv4 address prefix. **/ @@ -1433,6 +1433,7 @@ nm_ip4_address_set_prefix (NMIP4Address *address, guint32 prefix) g_return_if_fail (address != NULL); g_return_if_fail (address->refcount > 0); g_return_if_fail (prefix <= 32); + g_return_if_fail (prefix > 0); address->prefix = prefix; } @@ -1636,7 +1637,7 @@ nm_ip4_route_get_prefix (NMIP4Route *route) /** * nm_ip4_route_set_prefix: * @route: the #NMIP4Route - * @prefix: the prefix, a number between 0 and 32 inclusive + * @prefix: the prefix, a number between 1 and 32 inclusive * * Sets the IPv4 prefix of this route. **/ @@ -1645,6 +1646,8 @@ nm_ip4_route_set_prefix (NMIP4Route *route, guint32 prefix) { g_return_if_fail (route != NULL); g_return_if_fail (route->refcount > 0); + g_return_if_fail (prefix <= 32); + g_return_if_fail (prefix > 0); route->prefix = prefix; } -- cgit v1.2.1