nm-ip-config: escape searches when exposing to dbus
Previously, when a connection was configured with search domains that contained non-ASCII characters, GLib would try to parse the search name as UTF-8, and an assertion would fail (which meant that if NM was running with fatal assertions, it would crash). Expose the search domains only as an escaped string to avoid this.
This commit is contained in:
@@ -162,6 +162,7 @@ get_property_ip(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec
|
|||||||
NMIPConfig *self = NM_IP_CONFIG(object);
|
NMIPConfig *self = NM_IP_CONFIG(object);
|
||||||
NMIPConfigPrivate *priv = NM_IP_CONFIG_GET_PRIVATE(self);
|
NMIPConfigPrivate *priv = NM_IP_CONFIG_GET_PRIVATE(self);
|
||||||
const int addr_family = nm_ip_config_get_addr_family(self);
|
const int addr_family = nm_ip_config_get_addr_family(self);
|
||||||
|
char **to_free = NULL;
|
||||||
char sbuf_addr[NM_INET_ADDRSTRLEN];
|
char sbuf_addr[NM_INET_ADDRSTRLEN];
|
||||||
const char *const *strv;
|
const char *const *strv;
|
||||||
guint len;
|
guint len;
|
||||||
@@ -193,7 +194,20 @@ get_property_ip(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec
|
|||||||
break;
|
break;
|
||||||
case PROP_IP_SEARCHES:
|
case PROP_IP_SEARCHES:
|
||||||
strv = nm_l3_config_data_get_searches(priv->l3cd, addr_family, &len);
|
strv = nm_l3_config_data_get_searches(priv->l3cd, addr_family, &len);
|
||||||
|
if (strv) {
|
||||||
|
strv = nm_utils_buf_utf8safe_escape_strv(
|
||||||
|
strv,
|
||||||
|
-1,
|
||||||
|
NM_UTILS_STR_UTF8_SAFE_FLAG_ESCAPE_CTRL
|
||||||
|
| NM_UTILS_STR_UTF8_SAFE_FLAG_ESCAPE_NON_ASCII,
|
||||||
|
&to_free);
|
||||||
|
}
|
||||||
|
|
||||||
_value_set_variant_as(value, strv, len);
|
_value_set_variant_as(value, strv, len);
|
||||||
|
|
||||||
|
if (to_free) {
|
||||||
|
g_strfreev(to_free);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case PROP_IP_DNS_PRIORITY:
|
case PROP_IP_DNS_PRIORITY:
|
||||||
v_i = nm_l3_config_data_get_dns_priority_or_default(priv->l3cd, addr_family);
|
v_i = nm_l3_config_data_get_dns_priority_or_default(priv->l3cd, addr_family);
|
||||||
|
Reference in New Issue
Block a user