[Telepathy-commits] [telepathy-gabble/master] AcceptStreamTube: handle bad parameters correctly
Alban Crequy
alban.crequy at collabora.co.uk
Tue Nov 11 12:03:07 PST 2008
---
src/tube-stream.c | 16 ++++++++++------
src/tubes-channel.c | 13 ++++++++++++-
2 files changed, 22 insertions(+), 7 deletions(-)
diff --git a/src/tube-stream.c b/src/tube-stream.c
index c2284df..e813883 100644
--- a/src/tube-stream.c
+++ b/src/tube-stream.c
@@ -1149,9 +1149,6 @@ gabble_tube_stream_set_property (GObject *object,
}
break;
case PROP_ACCESS_CONTROL:
- /* For now, only "localhost" control is implemented */
- g_assert (g_value_get_uint (value) ==
- TP_SOCKET_ACCESS_CONTROL_LOCALHOST);
priv->access_control = g_value_get_uint (value);
break;
case PROP_ACCESS_CONTROL_PARAM:
@@ -1531,20 +1528,20 @@ gabble_tube_stream_accept (GabbleTubeIface *tube,
if (!gabble_tube_stream_check_params (priv->address_type, NULL,
priv->access_control, priv->access_control_param, error))
{
- return FALSE;
+ goto fail;
}
if (priv->state != GABBLE_TUBE_CHANNEL_STATE_LOCAL_PENDING)
{
g_set_error (error, TP_ERRORS, TP_ERROR_INVALID_ARGUMENT,
"Tube is not in the local pending state");
- return FALSE;
+ goto fail;
}
if (!tube_stream_open (self, error))
{
gabble_tube_iface_close (GABBLE_TUBE_IFACE (self), TRUE);
- return FALSE;
+ goto fail;
}
priv->state = GABBLE_TUBE_CHANNEL_STATE_OPEN;
@@ -1555,6 +1552,13 @@ gabble_tube_stream_accept (GabbleTubeIface *tube,
g_signal_emit (G_OBJECT (self), signals[OPENED], 0);
return TRUE;
+
+fail:
+ priv->address_type = 0;
+ priv->access_control = 0;
+ tp_g_value_slice_free (priv->access_control_param);
+ priv->access_control_param = NULL;
+ return FALSE;
}
/**
diff --git a/src/tubes-channel.c b/src/tubes-channel.c
index 5091c11..f4e93a4 100644
--- a/src/tubes-channel.c
+++ b/src/tubes-channel.c
@@ -1935,7 +1935,18 @@ gabble_tubes_channel_accept_stream_tube (TpSvcChannelTypeTubes *iface,
return;
}
- /* parameters sanity checks are done in gabble_tube_stream_accept */
+ /* most parameters sanity checks are done in gabble_tube_stream_accept,
+ * but at least check that they fit the properties requirements */
+ if (address_type != TP_SOCKET_ADDRESS_TYPE_UNIX &&
+ address_type != TP_SOCKET_ADDRESS_TYPE_IPV4 &&
+ address_type != TP_SOCKET_ADDRESS_TYPE_IPV6)
+ {
+ GError e = { TP_ERRORS, TP_ERROR_INVALID_ARGUMENT,
+ "Address type not implemented" };
+
+ dbus_g_method_return_error (context, &e);
+ return;
+ }
g_object_set (tube,
"address-type", address_type,
"access-control", access_control,
--
1.5.6.5
More information about the Telepathy-commits
mailing list