mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-03 22:10:14 +01:00
core: minor refactoring iterating and removing list of routes
The previous version causes an unsigned integer underflow. That
is not wrong, but still change it.
Also use g_array_remove_index_fast() because the list of routes
is unsorted anyway.
(cherry picked from commit e7f3ccf7cd)
This commit is contained in:
parent
e04d0c6e6b
commit
1d2ff90a5c
2 changed files with 8 additions and 6 deletions
|
|
@ -201,7 +201,7 @@ nm_ip4_config_capture (int ifindex, gboolean capture_resolv_conf)
|
|||
|
||||
/* Extract gateway from default route */
|
||||
old_gateway = priv->gateway;
|
||||
for (i = 0; i < priv->routes->len; i++) {
|
||||
for (i = 0; i < priv->routes->len; ) {
|
||||
const NMPlatformIP4Route *route = &g_array_index (priv->routes, NMPlatformIP4Route, i);
|
||||
|
||||
if (NM_PLATFORM_IP_ROUTE_IS_DEFAULT (route)) {
|
||||
|
|
@ -211,9 +211,10 @@ nm_ip4_config_capture (int ifindex, gboolean capture_resolv_conf)
|
|||
}
|
||||
has_gateway = TRUE;
|
||||
/* Remove the default route from the list */
|
||||
g_array_remove_index (priv->routes, i);
|
||||
i--;
|
||||
g_array_remove_index_fast (priv->routes, i);
|
||||
continue;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
/* If there is a host route to the gateway, ignore that route. It is
|
||||
|
|
|
|||
|
|
@ -313,7 +313,7 @@ nm_ip6_config_capture (int ifindex, gboolean capture_resolv_conf, NMSettingIP6Co
|
|||
|
||||
/* Extract gateway from default route */
|
||||
old_gateway = priv->gateway;
|
||||
for (i = 0; i < priv->routes->len; i++) {
|
||||
for (i = 0; i < priv->routes->len; ) {
|
||||
const NMPlatformIP6Route *route = &g_array_index (priv->routes, NMPlatformIP6Route, i);
|
||||
|
||||
if (NM_PLATFORM_IP_ROUTE_IS_DEFAULT (route)) {
|
||||
|
|
@ -323,9 +323,10 @@ nm_ip6_config_capture (int ifindex, gboolean capture_resolv_conf, NMSettingIP6Co
|
|||
}
|
||||
has_gateway = TRUE;
|
||||
/* Remove the default route from the list */
|
||||
g_array_remove_index (priv->routes, i);
|
||||
i--;
|
||||
g_array_remove_index_fast (priv->routes, i);
|
||||
continue;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
/* If there is a host route to the gateway, ignore that route. It is
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue