diff options
Diffstat (limited to 'src/nm-ip4-config.c')
| -rw-r--r-- | src/nm-ip4-config.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/nm-ip4-config.c b/src/nm-ip4-config.c index 4b27edf7..75caf7e3 100644 --- a/src/nm-ip4-config.c +++ b/src/nm-ip4-config.c @@ -365,6 +365,8 @@ nm_ip4_config_commit (const NMIP4Config *config, int ifindex, gboolean routes_fu if (addr->plen == 0) continue; + nm_assert (addr->plen <= 32); + route.ifindex = ifindex; route.source = NM_IP_CONFIG_SOURCE_KERNEL; @@ -466,6 +468,7 @@ nm_ip4_config_merge_setting (NMIP4Config *config, NMSettingIPConfig *setting, gu nm_ip_address_get_address_binary (s_addr, &address.address); address.peer_address = address.address; address.plen = nm_ip_address_get_prefix (s_addr); + nm_assert (address.plen <= 32); address.lifetime = NM_PLATFORM_LIFETIME_PERMANENT; address.preferred = NM_PLATFORM_LIFETIME_PERMANENT; address.source = NM_IP_CONFIG_SOURCE_USER; @@ -486,7 +489,12 @@ nm_ip4_config_merge_setting (NMIP4Config *config, NMSettingIPConfig *setting, gu memset (&route, 0, sizeof (route)); nm_ip_route_get_dest_binary (s_route, &route.network); + route.plen = nm_ip_route_get_prefix (s_route); + nm_assert (route.plen <= 32); + if (route.plen == 0) + continue; + nm_ip_route_get_next_hop_binary (s_route, &route.gateway); if (nm_ip_route_get_metric (s_route) == -1) route.metric = default_route_metric; @@ -494,8 +502,6 @@ nm_ip4_config_merge_setting (NMIP4Config *config, NMSettingIPConfig *setting, gu route.metric = nm_ip_route_get_metric (s_route); route.source = NM_IP_CONFIG_SOURCE_USER; - g_assert (route.plen > 0); - nm_ip4_config_add_route (config, &route); } @@ -1328,7 +1334,7 @@ nm_ip4_config_dump (const NMIP4Config *config, const char *detail) } gboolean -nm_ip4_config_destination_is_direct (const NMIP4Config *config, guint32 network, int plen) +nm_ip4_config_destination_is_direct (const NMIP4Config *config, guint32 network, guint8 plen) { guint naddresses = nm_ip4_config_get_num_addresses (config); int i; @@ -1567,7 +1573,7 @@ nm_ip4_config_add_route (NMIP4Config *config, const NMPlatformIP4Route *new) int i; g_return_if_fail (new != NULL); - g_return_if_fail (new->plen > 0); + g_return_if_fail (new->plen > 0 && new->plen <= 32); g_assert (priv->ifindex); for (i = 0; i < priv->routes->len; i++ ) { |