From: Zbigniew Jędrzejewski-Szmek Date: Thu, 21 May 2020 05:40:31 +0000 (+0200) Subject: network: fix signed/unsigned confusion X-Git-Tag: v246-rc1~297^2~4 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a27060759bcdbf35a03a883a121838b8d281da20;p=thirdparty%2Fsystemd.git 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. --- diff --git a/src/network/networkd-dhcp-server.c b/src/network/networkd-dhcp-server.c index 2e9cef590ff..87659909a02 100644 --- a/src/network/networkd-dhcp-server.c +++ b/src/network/networkd-dhcp-server.c @@ -160,12 +160,12 @@ static int link_push_uplink_to_dhcp_server( if (lease_condition && link->dhcp_lease) { const struct in_addr *da; - size_t n = sd_dhcp_lease_get_servers(link->dhcp_lease, what, &da); + int n = sd_dhcp_lease_get_servers(link->dhcp_lease, what, &da); if (n > 0) { if (!GREEDY_REALLOC(addresses, n_allocated, n_addresses + n)) return log_oom(); - for (unsigned i = 0; i < n; i++) + for (int i = 0; i < n; i++) if (in4_addr_is_non_local(&da[i])) addresses[n_addresses++] = da[i]; }