From 0e48e549e7693f665b43bcad5e14ef26447bfe5b Mon Sep 17 00:00:00 2001 From: dequis Date: Wed, 25 May 2016 21:29:14 -0300 Subject: 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. --- protocols/purple/purple.c | 9 ++++++--- 1 file 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 */ -- cgit v1.2.3