From a27060759bcdbf35a03a883a121838b8d281da20 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Thu, 21 May 2020 07:40:31 +0200 Subject: [PATCH] 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. --- src/network/networkd-dhcp-server.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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]; } -- 2.39.5