Skip to content

Commit

Permalink
purple: strdup the message instead of casting to char *
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
dequis committed May 26, 2016
1 parent 21f450c commit 0e48e54
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions protocols/purple/purple.c
Expand Up @@ -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);
Expand All @@ -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 */
Expand Down

0 comments on commit 0e48e54

Please sign in to comment.