aboutsummaryrefslogtreecommitdiffstats
path: root/protocols/purple/purple.c
diff options
context:
space:
mode:
authordequis <dx@dxzone.com.ar>2016-05-25 21:29:14 -0300
committerdequis <dx@dxzone.com.ar>2016-05-25 21:29:14 -0300
commit0e48e549e7693f665b43bcad5e14ef26447bfe5b (patch)
tree97a7dfd5f4bd6dad01a7d7365b721f3b4375848b /protocols/purple/purple.c
parent21f450c5ebbdb6b57e6ae4e06943f16c637207ca (diff)
purple: strdup the message instead of casting to char *
Fixes trac ticket 1255, which points out that a strip_html() call down there may modify the passed string, and some purple plugins may pass read-only string data to it.
Diffstat (limited to 'protocols/purple/purple.c')
-rw-r--r--protocols/purple/purple.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/protocols/purple/purple.c b/protocols/purple/purple.c
index d0e8ec40..6ea2d7d8 100644
--- a/protocols/purple/purple.c
+++ b/protocols/purple/purple.c
@@ -964,10 +964,11 @@ void prplcb_conv_del_users(PurpleConversation *conv, GList *cbuddies)
}
/* Generic handler for IM or chat messages, covers write_chat, write_im and write_conv */
-static void handle_conv_msg(PurpleConversation *conv, const char *who, const char *message, guint32 bee_flags, time_t mtime)
+static void handle_conv_msg(PurpleConversation *conv, const char *who, const char *message_, guint32 bee_flags, time_t mtime)
{
struct im_connection *ic = purple_ic_by_pa(conv->account);
struct groupchat *gc = conv->ui_data;
+ char *message = g_strdup(message_);
PurpleBuddy *buddy;
buddy = purple_find_buddy(conv->account, who);
@@ -976,10 +977,12 @@ static void handle_conv_msg(PurpleConversation *conv, const char *who, const cha
}
if (conv->type == PURPLE_CONV_TYPE_IM) {
- imcb_buddy_msg(ic, (char *) who, (char *) message, bee_flags, mtime);
+ imcb_buddy_msg(ic, who, message, bee_flags, mtime);
} else if (gc) {
- imcb_chat_msg(gc, who, (char *) message, bee_flags, mtime);
+ imcb_chat_msg(gc, who, message, bee_flags, mtime);
}
+
+ g_free(message);
}
/* Handles write_im and write_chat. Removes echoes of locally sent messages */