From 6f99368935194dbdab043a25aa54deb8bd0dbbae Mon Sep 17 00:00:00 2001 From: Denis Kenzior Date: Fri, 4 Jun 2021 14:11:25 -0500 Subject: [PATCH] ip-pool: Use inet_ntop instead of inet_ntoa --- src/ip-pool.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/ip-pool.c b/src/ip-pool.c index 42c96bb4..509bbeb7 100644 --- a/src/ip-pool.c +++ b/src/ip-pool.c @@ -141,6 +141,7 @@ int ip_pool_select_addr4(const char **addr_str_list, uint8_t subnet_prefix_len, struct in_addr ia; const struct l_queue_entry *entry; int err = -EINVAL; + char ipstr[INET_ADDRSTRLEN]; /* Build a sorted list of used/unavailable subnets */ for (entry = l_queue_get_entries((struct l_queue *) used_addr4_list); @@ -242,7 +243,10 @@ check_avail: done: err = 0; ia.s_addr = htonl(host_addr); - *out_addr = l_rtnl_address_new(inet_ntoa(ia), subnet_prefix_len); + if (L_WARN_ON(!inet_ntop(AF_INET, &ia, ipstr, INET_ADDRSTRLEN))) + err = -errno; + else + *out_addr = l_rtnl_address_new(ipstr, subnet_prefix_len); cleanup: l_queue_destroy(ranges, l_free);