diff options
author | Olivier CrĂȘte <olivier.crete@collabora.com> | 2012-02-01 15:07:48 +0000 |
---|---|---|
committer | Nicolas Dufresne <nicolas.dufresne@collabora.com> | 2012-02-14 10:35:33 -0500 |
commit | b3cb12d0f32a4424efd708bd0bde5f3179a81a85 (patch) | |
tree | 2b41d343ed80f01e8d9a1ffb11fa53f7a6d132a3 | |
parent | 65226cf0e15b5b62bcef4e13a9fb03e1093d651a (diff) |
Call.Content.MediaDescription: Verify invalid arguments
-rw-r--r-- | telepathy-glib/base-media-call-content.c | 16 | ||||
-rw-r--r-- | telepathy-glib/call-content-media-description.c | 36 |
2 files changed, 50 insertions, 2 deletions
diff --git a/telepathy-glib/base-media-call-content.c b/telepathy-glib/base-media-call-content.c index d9e4a60ff..32639529c 100644 --- a/telepathy-glib/base-media-call-content.c +++ b/telepathy-glib/base-media-call-content.c @@ -682,6 +682,7 @@ tp_base_media_call_content_update_local_media_description ( { TpBaseMediaCallContent *self = TP_BASE_MEDIA_CALL_CONTENT (iface); GHashTable *current_properties; + GPtrArray *codecs; gpointer contact; if (self->priv->current_offer != NULL) @@ -693,7 +694,8 @@ tp_base_media_call_content_update_local_media_description ( return; } - if (!g_hash_table_lookup_extended (properties, "RemoteContact", + if (!g_hash_table_lookup_extended (properties, + TP_PROP_CALL_CONTENT_MEDIA_DESCRIPTION_REMOTE_CONTACT, NULL, &contact)) { GError error = { TP_ERRORS, TP_ERROR_INVALID_ARGUMENT, @@ -714,6 +716,18 @@ tp_base_media_call_content_update_local_media_description ( return; } + + codecs = tp_asv_get_boxed (properties, + TP_PROP_CALL_CONTENT_MEDIA_DESCRIPTION_CODECS, + TP_ARRAY_TYPE_CODEC_LIST); + if (!codecs || codecs->len == 0) + { + GError error = { TP_ERRORS, TP_ERROR_INVALID_ARGUMENT, + "Codecs can not be empty" }; + dbus_g_method_return_error (context, &error); + return; + } + set_local_properties (self, GPOINTER_TO_UINT (contact), properties); tp_svc_call_content_interface_media_return_from_update_local_media_description diff --git a/telepathy-glib/call-content-media-description.c b/telepathy-glib/call-content-media-description.c index a108f4dcd..8873178d1 100644 --- a/telepathy-glib/call-content-media-description.c +++ b/telepathy-glib/call-content-media-description.c @@ -621,6 +621,9 @@ tp_call_content_media_description_accept (TpSvcCallContentMediaDescription *ifac DBusGMethodInvocation *context) { TpCallContentMediaDescription *self = (TpCallContentMediaDescription *) iface; + GPtrArray *codecs; + gboolean valid; + TpHandle remote_contact; DEBUG ("%s was accepted", self->priv->object_path); @@ -631,6 +634,28 @@ tp_call_content_media_description_accept (TpSvcCallContentMediaDescription *ifac self->priv->handler_id = 0; } + codecs = tp_asv_get_boxed (properties, + TP_PROP_CALL_CONTENT_MEDIA_DESCRIPTION_CODECS, + TP_ARRAY_TYPE_CODEC_LIST); + if (!codecs || codecs->len == 0) + { + GError error = { TP_ERRORS, TP_ERROR_INVALID_ARGUMENT, + "Codecs can not be empty" }; + dbus_g_method_return_error (context, &error); + return; + } + + remote_contact = tp_asv_get_uint32 (properties, + TP_PROP_CALL_CONTENT_MEDIA_DESCRIPTION_REMOTE_CONTACT, + &valid); + if (valid && remote_contact != self->priv->remote_contact) + { + GError error = { TP_ERRORS, TP_ERROR_INVALID_ARGUMENT, + "Remote contact must the same as in request." }; + dbus_g_method_return_error (context, &error); + return; + } + g_simple_async_result_set_op_res_gpointer (self->priv->result, g_hash_table_ref (properties), (GDestroyNotify) g_hash_table_unref); g_simple_async_result_complete (self->priv->result); @@ -650,9 +675,18 @@ tp_call_content_media_description_reject (TpSvcCallContentMediaDescription *ifac DEBUG ("%s was rejected", self->priv->object_path); + if (!self->priv->has_remote_information) + { + GError error = { TP_ERRORS, TP_ERROR_INVALID_ARGUMENT, + "Can not reject an empty Media Description" }; + dbus_g_method_return_error (context, &error); + return; + } + if (self->priv->cancellable != NULL) { - g_cancellable_disconnect (self->priv->cancellable, self->priv->handler_id); + g_cancellable_disconnect (self->priv->cancellable, + self->priv->handler_id); g_clear_object (&self->priv->cancellable); self->priv->handler_id = 0; } |