mirror of
https://github.com/morgan9e/systemd
synced 2026-04-14 00:14:32 +09:00
network-internal: do not save partially parsed values
This commit is contained in:
@@ -261,8 +261,7 @@ int deserialize_dhcp_routes(struct sd_dhcp_route **ret, size_t *ret_size, const
|
||||
if (r == 0)
|
||||
break;
|
||||
|
||||
if (!GREEDY_REALLOC(routes, size + 1))
|
||||
return -ENOMEM;
|
||||
struct sd_dhcp_route route = {};
|
||||
|
||||
tok = word;
|
||||
|
||||
@@ -272,7 +271,7 @@ int deserialize_dhcp_routes(struct sd_dhcp_route **ret, size_t *ret_size, const
|
||||
continue;
|
||||
*tok_end = '\0';
|
||||
|
||||
r = inet_aton(tok, &routes[size].dst_addr);
|
||||
r = inet_aton(tok, &route.dst_addr);
|
||||
if (r == 0)
|
||||
continue;
|
||||
|
||||
@@ -289,15 +288,18 @@ int deserialize_dhcp_routes(struct sd_dhcp_route **ret, size_t *ret_size, const
|
||||
if (r < 0 || n > 32)
|
||||
continue;
|
||||
|
||||
routes[size].dst_prefixlen = (uint8_t) n;
|
||||
route.dst_prefixlen = (uint8_t) n;
|
||||
tok = tok_end + 1;
|
||||
|
||||
/* get the gateway */
|
||||
r = inet_aton(tok, &routes[size].gw_addr);
|
||||
r = inet_aton(tok, &route.gw_addr);
|
||||
if (r == 0)
|
||||
continue;
|
||||
|
||||
size++;
|
||||
if (!GREEDY_REALLOC(routes, size + 1))
|
||||
return -ENOMEM;
|
||||
|
||||
routes[size++] = route;
|
||||
}
|
||||
|
||||
*ret_size = size;
|
||||
|
||||
Reference in New Issue
Block a user