libpurple 32532:132ab72f81c5: jabber: Clean up the Carbons code.
commits at adium.im
commits at adium.im
Wed Oct 23 14:22:55 UTC 2013
details: http://hg.adium.im/libpurple/rev/132ab72f81c5
revision: 32532:132ab72f81c5
branch: adium
author: Thijs Alkemade <thijsalkemade at gmail.com>
date: Thu Jun 06 21:35:19 2013 +0200
jabber: Clean up the Carbons code.
Subject: libpurple 32533:42d2af18bdbf: jabber: Update carbons support to version urn:xmpp:carbons:2.
details: http://hg.adium.im/libpurple/rev/42d2af18bdbf
revision: 32533:42d2af18bdbf
branch: adium
author: Thijs Alkemade <me at thijsalkema.de>
date: Fri Jun 07 11:20:38 2013 +0200
jabber: Update carbons support to version urn:xmpp:carbons:2.
Subject: libpurple 32534:faacd84b29bc: Patch from fain: check whether the passed arguments are equal to the current values in the setters of ft.c before freeing them. This should fix crashes when receiving file transfers.
details: http://hg.adium.im/libpurple/rev/faacd84b29bc
revision: 32534:faacd84b29bc
branch: adium
author: Thijs Alkemade <me at thijsalkema.de>
date: Wed Oct 23 16:22:26 2013 +0200
Patch from fain: check whether the passed arguments are equal to the current values in the setters of ft.c before freeing them. This should fix crashes when receiving file transfers.
Refs #15755
diffs (162 lines):
diff -r 5340f4a9bd6a -r faacd84b29bc libpurple/ft.c
--- a/libpurple/ft.c Wed Jun 05 01:53:57 2013 +0200
+++ b/libpurple/ft.c Wed Oct 23 16:22:26 2013 +0200
@@ -914,9 +914,10 @@
purple_xfer_set_message(PurpleXfer *xfer, const char *message)
{
g_return_if_fail(xfer != NULL);
-
- g_free(xfer->message);
- xfer->message = g_strdup(message);
+ if (message != xfer->message) {
+ g_free(xfer->message);
+ xfer->message = g_strdup(message);
+ }
}
void
@@ -924,8 +925,10 @@
{
g_return_if_fail(xfer != NULL);
- g_free(xfer->filename);
- xfer->filename = g_strdup(filename);
+ if (filename != xfer->filename) {
+ g_free(xfer->filename);
+ xfer->filename = g_strdup(filename);
+ }
}
void
@@ -933,8 +936,10 @@
{
g_return_if_fail(xfer != NULL);
- g_free(xfer->local_filename);
- xfer->local_filename = g_strdup(filename);
+ if (filename != xfer->local_filename) {
+ g_free(xfer->local_filename);
+ xfer->local_filename = g_strdup(filename);
+ }
}
void
@@ -1679,8 +1684,9 @@
{
PurpleXferPrivData *priv = g_hash_table_lookup(xfers_data, xfer);
- g_free(priv->thumbnail_data);
- g_free(priv->thumbnail_mimetype);
+ /* Hold onto these in case they are equal to passed-in pointers */
+ gpointer *old_thumbnail_data = priv->thumbnail_data;
+ const gchar *old_mimetype = priv->thumbnail_mimetype;
if (thumbnail && size > 0) {
priv->thumbnail_data = g_memdup(thumbnail, size);
@@ -1691,6 +1697,10 @@
priv->thumbnail_size = 0;
priv->thumbnail_mimetype = NULL;
}
+
+ /* Now it's safe to free the pointers */
+ g_free(old_thumbnail_data);
+ g_free(old_mimetype);
}
void
diff -r 5340f4a9bd6a -r faacd84b29bc libpurple/protocols/jabber/message.c
--- a/libpurple/protocols/jabber/message.c Wed Jun 05 01:53:57 2013 +0200
+++ b/libpurple/protocols/jabber/message.c Wed Oct 23 16:22:26 2013 +0200
@@ -517,42 +517,37 @@
from = xmlnode_get_attrib(packet, "from");
if (jabber_is_own_account(js, from)) {
- for(child = packet->child; child; child = child->next) {
- const char *xmlns = xmlnode_get_namespace(child);
+ xmlnode *received = xmlnode_get_child_with_namespace(packet, "received", NS_XMPP_CARBONS);
+ xmlnode *sent = xmlnode_get_child_with_namespace(packet, "sent", NS_XMPP_CARBONS);
- if (purple_strequal(child->name, "forwarded") && purple_strequal(xmlns, NS_XMPP_FORWARD)) {
- xmlnode *subchild;
+ if (sent)
+ is_outgoing = TRUE;
- for(subchild = child->child; subchild; subchild = subchild->next) {
- const char *sub_xmlns = xmlnode_get_namespace(subchild);
+ if (received || sent) {
+ xmlnode *forwarded = xmlnode_get_child_with_namespace(received ? received : sent, "forwarded", NS_XMPP_FORWARD);
- if (purple_strequal(subchild->name, "message")
- && purple_strequal(sub_xmlns, NS_XMPP_CLIENT)) {
+ if (forwarded) {
+ xmlnode *message = xmlnode_get_child_with_namespace(forwarded, "message", NS_XMPP_CLIENT);
+ xmlnode *delay = xmlnode_get_child_with_namespace(forwarded, "delay", NS_DELAYED_DELIVERY);
- /* This is the forwarded message, handle this instead */
- purple_debug_info("jabber", "It's a carbon-copy, using the wrapped message instead.\n");
- packet = subchild;
- } else if(purple_strequal(subchild->name, "delay")
- && purple_strequal(sub_xmlns, NS_DELAYED_DELIVERY)) {
+ if (message) {
+ purple_debug_info("jabber", "It's a carbon-copy message, using the wrapped message instead.\n");
+ packet = message;
- const char *timestamp = xmlnode_get_attrib(subchild, "stamp");
- purple_debug_info("jabber", "Found a delay stamp: %s\n", timestamp);
- delayed = TRUE;
- if(timestamp)
+ if (delay) {
+ const char *timestamp = xmlnode_get_attrib(delay, "stamp");
+
+ if(timestamp) {
+ purple_debug_info("jabber", "Found a delay stamp: %s\n", timestamp);
+
+ delayed = TRUE;
+
message_timestamp = purple_str_to_time(timestamp, TRUE, NULL, NULL, NULL);
+ }
}
}
- } else if (purple_strequal(child->name, "received")
- && purple_strequal(xmlns, NS_XMPP_CARBONS)) {
-
- purple_debug_info("jabber", "It is an incoming message.\n");
- is_outgoing = FALSE;
- } else if (purple_strequal(child->name, "sent")
- && purple_strequal(xmlns, NS_XMPP_CARBONS)) {
- purple_debug_info("jabber", "It is an outgoing message.\n");
- is_outgoing = TRUE;
}
- }
+ }
}
from = xmlnode_get_attrib(packet, "from");
@@ -1368,7 +1363,7 @@
gboolean has_carbons = !purple_account_get_bool(purple_connection_get_account(gc), "carbons", FALSE);
xmlnode *node;
- if(has_carbons) {
+ if (has_carbons) {
node = xmlnode_new_child(iq->node, "enable");
} else {
node = xmlnode_new_child(iq->node, "disable");
@@ -1379,5 +1374,6 @@
xmlnode_set_namespace(node, NS_XMPP_CARBONS);
jabber_iq_send(iq);
+ /* Force an update of the account actions. */
purple_prpl_got_account_actions(purple_connection_get_account(gc));
}
diff -r 5340f4a9bd6a -r faacd84b29bc libpurple/protocols/jabber/namespaces.h
--- a/libpurple/protocols/jabber/namespaces.h Wed Jun 05 01:53:57 2013 +0200
+++ b/libpurple/protocols/jabber/namespaces.h Wed Oct 23 16:22:26 2013 +0200
@@ -96,7 +96,7 @@
#define NS_THUMBS "urn:xmpp:thumbs:0"
/* XEP-0280 Message Carbons */
-#define NS_XMPP_CARBONS "urn:xmpp:carbons:1"
+#define NS_XMPP_CARBONS "urn:xmpp:carbons:2"
/* XEP-0297 Message Forwarding */
#define NS_XMPP_FORWARD "urn:xmpp:forward:0"
More information about the commits
mailing list