Mercurial > pidgin.yaz
comparison src/protocols/msn/msg.c @ 5310:f4912a833ff6
[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 <tailor@pidgin.im>
author | Christian Hammond <chipx86@chipx86.com> |
---|---|
date | Tue, 06 May 2003 04:27:38 +0000 |
parents | e2e53316a21d |
children | b1c430fbf9d5 |
comparison
equal
deleted
inserted
replaced
5309:e2e53316a21d | 5310:f4912a833ff6 |
---|---|
88 GET_NEXT(tmp); /* Skip the username or flag */ | 88 GET_NEXT(tmp); /* Skip the username or flag */ |
89 msg->size = atoi(tmp); | 89 msg->size = atoi(tmp); |
90 | 90 |
91 if (msg->size != strlen(strchr(str, '\n') + 1)) { | 91 if (msg->size != strlen(strchr(str, '\n') + 1)) { |
92 gaim_debug(GAIM_DEBUG_ERROR, "msn", | 92 gaim_debug(GAIM_DEBUG_ERROR, "msn", |
93 "Message size (%d) and string length (%d) " | 93 "Incoming message size (%d) and string length (%d) " |
94 "do not match!\n", msg->size, strlen(str)); | 94 "do not match!\n", msg->size, strlen(str)); |
95 } | 95 } |
96 | 96 |
97 /* | 97 /* |
98 * We're going to make sure this is incoming by checking field1. | 98 * We're going to make sure this is incoming by checking field1. |
108 } | 108 } |
109 | 109 |
110 if (msg->incoming) { | 110 if (msg->incoming) { |
111 msg->sender = msn_users_find_with_passport(session->users, field1); | 111 msg->sender = msn_users_find_with_passport(session->users, field1); |
112 | 112 |
113 gaim_debug(GAIM_DEBUG_MISC, "msn", "incoming message: %s, %s\n", | |
114 field1, field2); | |
115 if (msg->sender == NULL) | 113 if (msg->sender == NULL) |
116 msg->sender = msn_user_new(session, field1, field2); | 114 msg->sender = msn_user_new(session, field1, field2); |
117 else | 115 else |
118 msn_user_ref(msg->sender); | 116 msn_user_ref(msg->sender); |
119 } | 117 } |
194 | 192 |
195 char * | 193 char * |
196 msn_message_build_string(const MsnMessage *msg) | 194 msn_message_build_string(const MsnMessage *msg) |
197 { | 195 { |
198 GList *l; | 196 GList *l; |
197 char *msg_start; | |
199 char *str; | 198 char *str; |
200 char buf[MSN_BUF_LEN]; | 199 char buf[MSN_BUF_LEN]; |
201 int len; | 200 int len; |
202 | 201 |
203 /* | 202 /* |
228 | 227 |
229 str = g_new0(char, len); | 228 str = g_new0(char, len); |
230 | 229 |
231 g_strlcpy(str, buf, len); | 230 g_strlcpy(str, buf, len); |
232 | 231 |
232 msg_start = str + strlen(str); | |
233 | |
233 /* Standard header. */ | 234 /* Standard header. */ |
234 if (msg->charset == NULL) { | 235 if (msg->charset == NULL) { |
235 g_snprintf(buf, sizeof(buf), | 236 g_snprintf(buf, sizeof(buf), |
236 "MIME-Version: 1.0\r\n" | 237 "MIME-Version: 1.0\r\n" |
237 "Content-Type: %s\r\n", | 238 "Content-Type: %s\r\n", |
259 | 260 |
260 g_snprintf(buf, sizeof(buf), "\r\n%s", msn_message_get_body(msg)); | 261 g_snprintf(buf, sizeof(buf), "\r\n%s", msn_message_get_body(msg)); |
261 | 262 |
262 g_strlcat(str, buf, len); | 263 g_strlcat(str, buf, len); |
263 | 264 |
265 if (msg->size != strlen(msg_start)) { | |
266 gaim_debug(GAIM_DEBUG_ERROR, "msn", | |
267 "Outgoing message size (%d) and string length (%d) " | |
268 "do not match!\n", msg->size, strlen(msg_start)); | |
269 } | |
270 | |
264 return str; | 271 return str; |
265 } | 272 } |
266 | 273 |
267 gboolean | 274 gboolean |
268 msn_message_is_outgoing(const MsnMessage *msg) | 275 msn_message_is_outgoing(const MsnMessage *msg) |
440 | 447 |
441 if (value == NULL) { | 448 if (value == NULL) { |
442 if (temp != NULL) { | 449 if (temp != NULL) { |
443 GList *l; | 450 GList *l; |
444 | 451 |
452 msg->size -= strlen(temp) + strlen(attr) + 4; | |
453 | |
445 for (l = msg->attr_list; l != NULL; l = l->next) { | 454 for (l = msg->attr_list; l != NULL; l = l->next) { |
446 if (!g_ascii_strcasecmp(l->data, attr)) { | 455 if (!g_ascii_strcasecmp(l->data, attr)) { |
447 msg->attr_list = g_list_remove(msg->attr_list, l->data); | 456 msg->attr_list = g_list_remove(msg->attr_list, l->data); |
448 | 457 |
449 break; | 458 break; |
450 } | 459 } |
451 } | 460 } |
452 | 461 |
453 g_hash_table_remove(msg->attr_table, attr); | 462 g_hash_table_remove(msg->attr_table, attr); |
454 | |
455 msg->size -= strlen(temp) + strlen(attr) + 4; | |
456 } | 463 } |
457 | 464 |
458 return; | 465 return; |
459 } | 466 } |
460 | 467 |