diff options
author | Thomas Haller <thaller@redhat.com> | 2018-11-26 16:49:51 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2018-12-19 09:23:08 +0100 |
commit | a51c09dc12e2f1ba53a2239a0239fe98f66d628e (patch) | |
tree | 0df4dcbfa8c57e0198b5bfddba410e219c0e27e7 /src/nm-pacrunner-manager.c | |
parent | 898f7a56655de1edf0bcb8036d3a8ca71b19c536 (diff) | |
download | NetworkManager-a51c09dc12e2f1ba53a2239a0239fe98f66d628e.tar.gz |
all: don't use static buffer for nm_utils_inet*_ntop()
While nm_utils_inet*_ntop() accepts a %NULL buffer to fallback
to a static buffer, don't do that.
I find the possibility of using a static buffer here error prone
and something that should be avoided. There is of course the downside,
that in some cases it requires an additional line of code to allocate
the buffer on the stack as auto-variable.
Diffstat (limited to 'src/nm-pacrunner-manager.c')
-rw-r--r-- | src/nm-pacrunner-manager.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/nm-pacrunner-manager.c b/src/nm-pacrunner-manager.c index 677e56e393..b9881f76f2 100644 --- a/src/nm-pacrunner-manager.c +++ b/src/nm-pacrunner-manager.c @@ -173,6 +173,7 @@ get_ip4_domains (GPtrArray *domains, NMIP4Config *ip4) const NMPlatformIP4Address *address; const NMPlatformIP4Route *routes; guint i; + char sbuf[NM_UTILS_INET_ADDRSTRLEN]; /* Extract searches */ for (i = 0; i < nm_ip4_config_get_num_searches (ip4); i++) @@ -186,7 +187,7 @@ get_ip4_domains (GPtrArray *domains, NMIP4Config *ip4) nm_ip_config_iter_ip4_address_for_each (&ipconf_iter, ip4, &address) { cidr = g_strdup_printf ("%s/%u", - nm_utils_inet4_ntop (address->address, NULL), + nm_utils_inet4_ntop (address->address, sbuf), address->plen); g_ptr_array_add (domains, cidr); } @@ -195,7 +196,7 @@ get_ip4_domains (GPtrArray *domains, NMIP4Config *ip4) if (NM_PLATFORM_IP_ROUTE_IS_DEFAULT (routes)) continue; cidr = g_strdup_printf ("%s/%u", - nm_utils_inet4_ntop (routes->network, NULL), + nm_utils_inet4_ntop (routes->network, sbuf), routes->plen); g_ptr_array_add (domains, cidr); } @@ -209,6 +210,7 @@ get_ip6_domains (GPtrArray *domains, NMIP6Config *ip6) const NMPlatformIP6Address *address; const NMPlatformIP6Route *routes; guint i; + char sbuf[NM_UTILS_INET_ADDRSTRLEN]; /* Extract searches */ for (i = 0; i < nm_ip6_config_get_num_searches (ip6); i++) @@ -221,7 +223,7 @@ get_ip6_domains (GPtrArray *domains, NMIP6Config *ip6) /* Add addresses and routes in CIDR form */ nm_ip_config_iter_ip6_address_for_each (&ipconf_iter, ip6, &address) { cidr = g_strdup_printf ("%s/%u", - nm_utils_inet6_ntop (&address->address, NULL), + nm_utils_inet6_ntop (&address->address, sbuf), address->plen); g_ptr_array_add (domains, cidr); } @@ -230,7 +232,7 @@ get_ip6_domains (GPtrArray *domains, NMIP6Config *ip6) if (NM_PLATFORM_IP_ROUTE_IS_DEFAULT (routes)) continue; cidr = g_strdup_printf ("%s/%u", - nm_utils_inet6_ntop (&routes->network, NULL), + nm_utils_inet6_ntop (&routes->network, sbuf), routes->plen); g_ptr_array_add (domains, cidr); } |