platform: change @plen field of NMPlatformIPxRoute to type guint8

On netlink layer, this field is uint8_t/uchar.

A larger (signed) plen makes no sense. Adjust the signatures
to have only guint8.
This commit is contained in:
Thomas Haller
2016-04-06 14:19:05 +02:00
parent b1e3deaf2f
commit 14ee5dd2f8
18 changed files with 83 additions and 62 deletions

View File

@@ -312,7 +312,8 @@ lease_to_ip4_config (const char *iface,
continue;
route.network = a.s_addr;
if (sd_dhcp_route_get_destination_prefix_length (routes[i], &plen) < 0)
if ( sd_dhcp_route_get_destination_prefix_length (routes[i], &plen) < 0
|| plen > 32)
continue;
route.plen = plen;

View File

@@ -60,7 +60,7 @@ ip4_process_dhcpcd_rfc3442_routes (const char *str,
*slash = '\0';
errno = 0;
rt_cidr = strtol (slash + 1, NULL, 10);
if ((errno == EINVAL) || (errno == ERANGE)) {
if (errno || rt_cidr > 32) {
nm_log_warn (LOGD_DHCP4, "DHCP provided invalid classless static route cidr: '%s'", slash + 1);
continue;
}

View File

@@ -208,6 +208,8 @@ ip4_test_route (NMIP4Config *ip4_config,
const NMPlatformIP4Route *route;
guint32 tmp;
g_assert (expected_prefix <= 32);
route = nm_ip4_config_get_route (ip4_config, route_num);
g_assert (inet_pton (AF_INET, expected_dest, &tmp) > 0);
g_assert (route->network == tmp);