Skip to content

Commit a270607

Browse files
committed
network: fix signed/unsigned confusion
sd_dhcp_lease_get_servers() returns int, which would never be negative when cast to size_t, so we condition check was wrong. CID#1425417.
1 parent a60416f commit a270607

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/network/networkd-dhcp-server.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,12 +160,12 @@ static int link_push_uplink_to_dhcp_server(
160160
if (lease_condition && link->dhcp_lease) {
161161
const struct in_addr *da;
162162

163-
size_t n = sd_dhcp_lease_get_servers(link->dhcp_lease, what, &da);
163+
int n = sd_dhcp_lease_get_servers(link->dhcp_lease, what, &da);
164164
if (n > 0) {
165165
if (!GREEDY_REALLOC(addresses, n_allocated, n_addresses + n))
166166
return log_oom();
167167

168-
for (unsigned i = 0; i < n; i++)
168+
for (int i = 0; i < n; i++)
169169
if (in4_addr_is_non_local(&da[i]))
170170
addresses[n_addresses++] = da[i];
171171
}

0 commit comments

Comments
 (0)