From 57d94e792ff27ec79ea7ffd1544ab4340c257e08 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Mon, 21 Oct 2019 13:14:50 +0200 Subject: [PATCH] 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. --- libnm-core/nm-utils.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/libnm-core/nm-utils.c b/libnm-core/nm-utils.c index 8256bd833..2246c1131 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;