Commit d047ca34 authored by Florian Müllner's avatar Florian Müllner Committed by Matthias Clasen

portal network monitor: Validate connectivity

Only accept connectivity values that are actually
in the range of GNetworkConnectivity.

GNOME/glib!227
parent 860735f0
Pipeline #26995 passed with stages
in 17 minutes and 13 seconds
......@@ -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
got_available (GObject *source,
GAsyncResult *res,
......@@ -228,7 +242,8 @@ got_connectivity (GObject *source,
g_variant_unref (ret);
}
if (nm->priv->connectivity != connectivity)
if (nm->priv->connectivity != connectivity &&
is_valid_connectivity (connectivity))
{
nm->priv->connectivity = connectivity;
g_object_notify (G_OBJECT (nm), "connectivity");
......@@ -292,7 +307,8 @@ got_status (GObject *source,
should_emit_changed = TRUE;
}
if (nm->priv->connectivity != connectivity)
if (nm->priv->connectivity != connectivity &&
is_valid_connectivity (connectivity))
{
nm->priv->connectivity = connectivity;
g_object_notify (G_OBJECT (nm), "connectivity");
......@@ -361,7 +377,8 @@ proxy_properties_changed (GDBusProxy *proxy,
if (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;
g_object_notify (G_OBJECT (nm), "connectivity");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment