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:
@@ -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);
|
||||
|
||||
g_variant_unref (ip_var);
|
||||
}
|
||||
dns[i] = NULL;
|
||||
|
Reference in New Issue
Block a user