diff options
author | Thomas Haller <thaller@redhat.com> | 2019-10-21 13:14:50 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2019-10-27 14:30:51 +0100 |
commit | 57d94e792ff27ec79ea7ffd1544ab4340c257e08 (patch) | |
tree | 179f79ccf04b2c91e473e145efdb6cc8e06975e0 | |
parent | 1cf4de20ebb7d8762565379bdb0c78ab6c086300 (diff) | |
download | NetworkManager-57d94e792ff27ec79ea7ffd1544ab4340c257e08.tar.gz |
libnm: don't emit g_warning() from nm_utils_ip6_dns_from_variant()
The library should not print to stdout/stderr. This function is used to
convert untrusted(!!) input to a normalized and sanitized strv array.
g_warning() is essentially an assertion, and it's wrong to do that
for untrusted data. If the caller had to pre-validate the array, then
having this function would be pointless.
-rw-r--r-- | libnm-core/nm-utils.c | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/libnm-core/nm-utils.c b/libnm-core/nm-utils.c index 8256bd833a..2246c11311 100644 --- a/libnm-core/nm-utils.c +++ b/libnm-core/nm-utils.c @@ -1728,7 +1728,9 @@ nm_utils_ip6_dns_to_variant (char **dns) * @value: a #GVariant of type 'aay' * * Utility function to convert a #GVariant of type 'aay' representing a list of - * IPv6 addresses into an array of IP address strings. + * IPv6 addresses into an array of IP address strings. Each "ay" entry must be + * a IPv6 address in binary form (16 bytes long). Invalid entries are silently + * ignored. * * Returns: (transfer full) (type utf8): a %NULL-terminated array of IP address strings. **/ @@ -1750,14 +1752,9 @@ nm_utils_ip6_dns_from_variant (GVariant *value) gsize length; const struct in6_addr *ip = g_variant_get_fixed_array (ip_var, &length, 1); - if (length != sizeof (struct in6_addr)) { - g_warning ("%s: ignoring invalid IP6 address of length %d", - __func__, (int) length); - g_variant_unref (ip_var); - continue; - } + if (length == sizeof (struct in6_addr)) + dns[i++] = nm_utils_inet6_ntop_dup (ip); - dns[i++] = nm_utils_inet6_ntop_dup (ip); g_variant_unref (ip_var); } dns[i] = NULL; |