From: Lennart Poettering Date: Mon, 16 Jul 2018 10:31:50 +0000 (+0200) Subject: networkd: fix overflow check X-Git-Tag: v240~900 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=9fb96abdfd412540bcc2959ee56ff4a14750ee3d;p=thirdparty%2Fsystemd.git networkd: fix overflow check Fixes: #9591 --- diff --git a/src/network/networkd-dhcp6.c b/src/network/networkd-dhcp6.c index 0fcd2cab3ef..fb729406ddb 100644 --- a/src/network/networkd-dhcp6.c +++ b/src/network/networkd-dhcp6.c @@ -119,7 +119,7 @@ static int dhcp6_pd_prefix_distribute(Link *dhcp6_link, Iterator *i, Link *link; Manager *manager = dhcp6_link->manager; union in_addr_union prefix; - uint8_t n_prefixes, n_used = 0; + uint64_t n_prefixes, n_used = 0; _cleanup_free_ char *buf = NULL; int r; @@ -132,17 +132,17 @@ static int dhcp6_pd_prefix_distribute(Link *dhcp6_link, Iterator *i, if (r < 0) return r; - n_prefixes = 1 << (64 - pd_prefix_len); + n_prefixes = UINT64_C(1) << (64 - pd_prefix_len); (void) in_addr_to_string(AF_INET6, &prefix, &buf); - log_link_debug(dhcp6_link, "Assigning up to %u prefixes from %s/%u", + log_link_debug(dhcp6_link, "Assigning up to %" PRIu64 " prefixes from %s/%u", n_prefixes, strnull(buf), pd_prefix_len); while (hashmap_iterate(manager->links, i, (void **)&link, NULL)) { Link *assigned_link; if (n_used == n_prefixes) { - log_link_debug(dhcp6_link, "Assigned %u/%u prefixes from %s/%u", + log_link_debug(dhcp6_link, "Assigned %" PRIu64 "/%" PRIu64 " prefixes from %s/%u", n_used, n_prefixes, strnull(buf), pd_prefix_len); return -EAGAIN; @@ -169,7 +169,7 @@ static int dhcp6_pd_prefix_distribute(Link *dhcp6_link, Iterator *i, continue; } else - log_link_debug(link, "Assigned prefix %u/%u %s/64 to link", + log_link_debug(link, "Assigned prefix %" PRIu64 "/%" PRIu64 " %s/64 to link", n_used + 1, n_prefixes, strnull(buf)); n_used++; @@ -181,7 +181,7 @@ static int dhcp6_pd_prefix_distribute(Link *dhcp6_link, Iterator *i, if (n_used < n_prefixes) { Route *route; - int n = n_used; + uint64_t n = n_used; r = route_new(&route); if (r < 0)