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.
This commit is contained in:
Thomas Haller
2019-10-21 13:14:50 +02:00
parent 1cf4de20eb
commit 57d94e792f

View File

@@ -1728,7 +1728,9 @@ nm_utils_ip6_dns_to_variant (char **dns)
* @value: a #GVariant of type 'aay' * @value: a #GVariant of type 'aay'
* *
* Utility function to convert a #GVariant of type 'aay' representing a list of * 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. * 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; gsize length;
const struct in6_addr *ip = g_variant_get_fixed_array (ip_var, &length, 1); const struct in6_addr *ip = g_variant_get_fixed_array (ip_var, &length, 1);
if (length != sizeof (struct in6_addr)) { if (length == sizeof (struct in6_addr))
g_warning ("%s: ignoring invalid IP6 address of length %d", dns[i++] = nm_utils_inet6_ntop_dup (ip);
__func__, (int) length);
g_variant_unref (ip_var);
continue;
}
dns[i++] = nm_utils_inet6_ntop_dup (ip);
g_variant_unref (ip_var); g_variant_unref (ip_var);
} }
dns[i] = NULL; dns[i] = NULL;