mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-04-16 04:28:05 +02:00
portal network monitor: Validate connectivity
Only accept connectivity values that are actually in the range of GNetworkConnectivity. https://gitlab.gnome.org/GNOME/glib/merge_requests/227
This commit is contained in:
parent
860735f01b
commit
d047ca341b
@ -92,6 +92,20 @@ g_network_monitor_portal_get_property (GObject *object,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
is_valid_connectivity (guint32 value)
|
||||||
|
{
|
||||||
|
GEnumValue *enum_value;
|
||||||
|
GEnumClass *enum_klass;
|
||||||
|
|
||||||
|
enum_klass = g_type_class_ref (G_TYPE_NETWORK_CONNECTIVITY);
|
||||||
|
enum_value = g_enum_get_value (enum_klass, value);
|
||||||
|
|
||||||
|
g_type_class_unref (enum_klass);
|
||||||
|
|
||||||
|
return enum_value != NULL;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
got_available (GObject *source,
|
got_available (GObject *source,
|
||||||
GAsyncResult *res,
|
GAsyncResult *res,
|
||||||
@ -228,7 +242,8 @@ got_connectivity (GObject *source,
|
|||||||
g_variant_unref (ret);
|
g_variant_unref (ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nm->priv->connectivity != connectivity)
|
if (nm->priv->connectivity != connectivity &&
|
||||||
|
is_valid_connectivity (connectivity))
|
||||||
{
|
{
|
||||||
nm->priv->connectivity = connectivity;
|
nm->priv->connectivity = connectivity;
|
||||||
g_object_notify (G_OBJECT (nm), "connectivity");
|
g_object_notify (G_OBJECT (nm), "connectivity");
|
||||||
@ -292,7 +307,8 @@ got_status (GObject *source,
|
|||||||
should_emit_changed = TRUE;
|
should_emit_changed = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nm->priv->connectivity != connectivity)
|
if (nm->priv->connectivity != connectivity &&
|
||||||
|
is_valid_connectivity (connectivity))
|
||||||
{
|
{
|
||||||
nm->priv->connectivity = connectivity;
|
nm->priv->connectivity = connectivity;
|
||||||
g_object_notify (G_OBJECT (nm), "connectivity");
|
g_object_notify (G_OBJECT (nm), "connectivity");
|
||||||
@ -361,7 +377,8 @@ proxy_properties_changed (GDBusProxy *proxy,
|
|||||||
if (ret)
|
if (ret)
|
||||||
{
|
{
|
||||||
GNetworkConnectivity connectivity = g_variant_get_uint32 (ret);
|
GNetworkConnectivity connectivity = g_variant_get_uint32 (ret);
|
||||||
if (nm->priv->connectivity != connectivity)
|
if (nm->priv->connectivity != connectivity &&
|
||||||
|
is_valid_connectivity (connectivity))
|
||||||
{
|
{
|
||||||
nm->priv->connectivity = connectivity;
|
nm->priv->connectivity = connectivity;
|
||||||
g_object_notify (G_OBJECT (nm), "connectivity");
|
g_object_notify (G_OBJECT (nm), "connectivity");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user