summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonny Lamb <jonny.lamb@collabora.co.uk>2011-09-02 16:29:04 +0100
committerJonny Lamb <jonny.lamb@collabora.co.uk>2011-09-02 16:40:15 +0100
commit9f8f181fd943f1e96f898c736ee4977d310b94a1 (patch)
tree582e34cf95a473ccc5bea4467a0f2840159ebf03
parent00a7c2fb7195374c39f2b9c9be8254822e5484e8 (diff)
connection: deal with not being able to hash self presence
If a data form is bad we might not be able to, so we shouldn't crash. Signed-off-by: Jonny Lamb <jonny.lamb@collabora.co.uk>
-rw-r--r--src/conn-presence.c13
-rw-r--r--src/connection.c31
-rw-r--r--src/connection.h2
3 files changed, 36 insertions, 10 deletions
diff --git a/src/conn-presence.c b/src/conn-presence.c
index 95552c015..255ef4fa1 100644
--- a/src/conn-presence.c
+++ b/src/conn-presence.c
@@ -1605,9 +1605,16 @@ conn_presence_signal_own_presence (GabbleConnection *self,
* <show>away</show>? */
}
- gabble_connection_fill_in_caps (self, message);
-
- ret = _gabble_connection_send (self, message, error);
+ if (!gabble_connection_fill_in_caps (self, message))
+ {
+ g_set_error (error, TP_ERRORS, TP_ERROR_INVALID_ARGUMENT,
+ "Unable to fill in caps on presence stanza");
+ ret = FALSE;
+ }
+ else
+ {
+ ret = _gabble_connection_send (self, message, error);
+ }
lm_message_unref (message);
diff --git a/src/connection.c b/src/connection.c
index 486ed841c..327f99980 100644
--- a/src/connection.c
+++ b/src/connection.c
@@ -2292,7 +2292,7 @@ connection_shut_down (TpBaseConnection *base)
tp_base_connection_finish_shutdown (base);
}
-void
+gboolean
gabble_connection_fill_in_caps (GabbleConnection *self,
LmMessage *presence_message)
{
@@ -2300,10 +2300,13 @@ gabble_connection_fill_in_caps (GabbleConnection *self,
LmMessageNode *node = lm_message_get_node (presence_message);
gchar *caps_hash;
gboolean share_v1, voice_v1, video_v1;
- GString *ext = g_string_new ("");
+ GString *ext;
/* XEP-0115 version 1.5 uses a verification string in the 'ver' attribute */
caps_hash = caps_hash_compute_from_self_presence (self);
+ if (caps_hash == NULL)
+ return FALSE;
+
node = lm_message_node_add_child (node, "c", NULL);
lm_message_node_set_attributes (
node,
@@ -2321,6 +2324,7 @@ gabble_connection_fill_in_caps (GabbleConnection *self,
/* XEP-0115 deprecates 'ext' feature bundles. But we still need
* BUNDLE_VOICE_V1 it for backward-compatibility with Gabble 0.2 */
+ ext = g_string_new ("");
g_string_append (ext, BUNDLE_PMUC_V1);
share_v1 = gabble_presence_has_cap (presence, NS_GOOGLE_FEAT_SHARE);
@@ -2339,6 +2343,8 @@ gabble_connection_fill_in_caps (GabbleConnection *self,
lm_message_node_set_attribute (node, "ext", ext->str);
g_string_free (ext, TRUE);
g_free (caps_hash);
+
+ return TRUE;
}
gboolean
@@ -2366,9 +2372,16 @@ gabble_connection_send_capabilities (GabbleConnection *self,
message = lm_message_new_with_sub_type (recipient, LM_MESSAGE_TYPE_PRESENCE,
LM_MESSAGE_SUB_TYPE_AVAILABLE);
- gabble_connection_fill_in_caps (self, message);
-
- ret = _gabble_connection_send (self, message, error);
+ if (!gabble_connection_fill_in_caps (self, message))
+ {
+ g_set_error (error, TP_ERRORS, TP_ERROR_INVALID_ARGUMENT,
+ "Unable to fill in caps on presence stanza");
+ ret = FALSE;
+ }
+ else
+ {
+ ret = _gabble_connection_send (self, message, error);
+ }
lm_message_unref (message);
@@ -2386,7 +2399,13 @@ gabble_connection_request_decloak (GabbleConnection *self,
LmMessageNode *decloak;
gboolean ret;
- gabble_connection_fill_in_caps (self, message);
+ if (!gabble_connection_fill_in_caps (self, message))
+ {
+ g_set_error (error, TP_ERRORS, TP_ERROR_INVALID_ARGUMENT,
+ "Unable to fill in caps on presence stanza");
+ lm_message_unref (message);
+ return FALSE;
+ }
decloak = lm_message_node_add_child (lm_message_get_node (message),
"temppres", NULL);
diff --git a/src/connection.h b/src/connection.h
index b548243f1..72062404f 100644
--- a/src/connection.h
+++ b/src/connection.h
@@ -237,7 +237,7 @@ gboolean gabble_connection_send_capabilities (GabbleConnection *self,
gboolean gabble_connection_request_decloak (GabbleConnection *self,
const gchar *to, const gchar *reason, GError **error);
-void gabble_connection_fill_in_caps (GabbleConnection *self,
+gboolean gabble_connection_fill_in_caps (GabbleConnection *self,
LmMessage *presence_message);
gboolean _gabble_connection_invisible_privacy_list_set_active (