# HG changeset patch # User Christian Hammond # Date 1052195258 0 # Node ID f4912a833ff64a8fc5e2961609706864910857f9 # Parent e2e53316a21d379b5579d619e16eb91727eb4031 [gaim-migrate @ 5682] Fixed the bug where typing notifications (actually, any message where an attribute was removed) would strlen() the value just freed. This was causing the message size to be wrong on occasion (and probably very wrong on other platforms), which MSN would then puke about and cause a disconnect from the Switchboard server. committer: Tailor Script diff -r e2e53316a21d -r f4912a833ff6 src/protocols/msn/msg.c --- a/src/protocols/msn/msg.c Tue May 06 02:06:56 2003 +0000 +++ b/src/protocols/msn/msg.c Tue May 06 04:27:38 2003 +0000 @@ -90,7 +90,7 @@ if (msg->size != strlen(strchr(str, '\n') + 1)) { gaim_debug(GAIM_DEBUG_ERROR, "msn", - "Message size (%d) and string length (%d) " + "Incoming message size (%d) and string length (%d) " "do not match!\n", msg->size, strlen(str)); } @@ -110,8 +110,6 @@ if (msg->incoming) { msg->sender = msn_users_find_with_passport(session->users, field1); - gaim_debug(GAIM_DEBUG_MISC, "msn", "incoming message: %s, %s\n", - field1, field2); if (msg->sender == NULL) msg->sender = msn_user_new(session, field1, field2); else @@ -196,6 +194,7 @@ msn_message_build_string(const MsnMessage *msg) { GList *l; + char *msg_start; char *str; char buf[MSN_BUF_LEN]; int len; @@ -230,6 +229,8 @@ g_strlcpy(str, buf, len); + msg_start = str + strlen(str); + /* Standard header. */ if (msg->charset == NULL) { g_snprintf(buf, sizeof(buf), @@ -261,6 +262,12 @@ g_strlcat(str, buf, len); + if (msg->size != strlen(msg_start)) { + gaim_debug(GAIM_DEBUG_ERROR, "msn", + "Outgoing message size (%d) and string length (%d) " + "do not match!\n", msg->size, strlen(msg_start)); + } + return str; } @@ -442,6 +449,8 @@ if (temp != NULL) { GList *l; + msg->size -= strlen(temp) + strlen(attr) + 4; + for (l = msg->attr_list; l != NULL; l = l->next) { if (!g_ascii_strcasecmp(l->data, attr)) { msg->attr_list = g_list_remove(msg->attr_list, l->data); @@ -451,8 +460,6 @@ } g_hash_table_remove(msg->attr_table, attr); - - msg->size -= strlen(temp) + strlen(attr) + 4; } return;