Mercurial > pidgin
comparison src/protocols/msn/msg.c @ 6831:a372cf34387e
[gaim-migrate @ 7376]
Fixed MSNSLP crashing!
committer: Tailor Script <tailor@pidgin.im>
| author | Christian Hammond <chipx86@chipx86.com> |
|---|---|
| date | Sun, 14 Sep 2003 03:22:52 +0000 |
| parents | 1cfbb731aa1f |
| children | bd433a45a463 |
comparison
equal
deleted
inserted
replaced
| 6830:7ed61a258cb2 | 6831:a372cf34387e |
|---|---|
| 354 len = strlen(buf) + msg->size + 1; | 354 len = strlen(buf) + msg->size + 1; |
| 355 | 355 |
| 356 str = g_new0(char, len + 1); | 356 str = g_new0(char, len + 1); |
| 357 | 357 |
| 358 g_strlcpy(str, buf, len); | 358 g_strlcpy(str, buf, len); |
| 359 gaim_debug_misc("msn", "msg->size = %d\n", msg->size); | |
| 360 | 359 |
| 361 msg_start = str + strlen(str); | 360 msg_start = str + strlen(str); |
| 362 gaim_debug_misc("msn", "msg->size = %d\n", msg->size); | |
| 363 | 361 |
| 364 /* Standard header. */ | 362 /* Standard header. */ |
| 365 if (msg->charset == NULL) { | 363 if (msg->charset == NULL) { |
| 366 g_snprintf(buf, sizeof(buf), | 364 g_snprintf(buf, sizeof(buf), |
| 367 "MIME-Version: 1.0\r\n" | 365 "MIME-Version: 1.0\r\n" |
| 372 g_snprintf(buf, sizeof(buf), | 370 g_snprintf(buf, sizeof(buf), |
| 373 "MIME-Version: 1.0\r\n" | 371 "MIME-Version: 1.0\r\n" |
| 374 "Content-Type: %s; charset=%s\r\n", | 372 "Content-Type: %s; charset=%s\r\n", |
| 375 msg->content_type, msg->charset); | 373 msg->content_type, msg->charset); |
| 376 } | 374 } |
| 377 gaim_debug_misc("msn", "msg->size = %d\n", msg->size); | |
| 378 | 375 |
| 379 g_strlcat(str, buf, len); | 376 g_strlcat(str, buf, len); |
| 380 gaim_debug_misc("msn", "msg->size = %d\n", msg->size); | |
| 381 | 377 |
| 382 for (l = msg->attr_list; l != NULL; l = l->next) { | 378 for (l = msg->attr_list; l != NULL; l = l->next) { |
| 383 const char *key = (char *)l->data; | 379 const char *key = (char *)l->data; |
| 384 const char *value; | 380 const char *value; |
| 385 | 381 |
| 397 char *c; | 393 char *c; |
| 398 long session_id, id, offset, total_size, length, flags; | 394 long session_id, id, offset, total_size, length, flags; |
| 399 long ack_session_id, ack_unique_id, ack_length; | 395 long ack_session_id, ack_unique_id, ack_length; |
| 400 | 396 |
| 401 c = str + strlen(str); | 397 c = str + strlen(str); |
| 402 | |
| 403 gaim_debug_misc("msn", "cur size = %d\n", (c - msg_start)); | |
| 404 gaim_debug_misc("msn", "msg->size = %d\n", msg->size); | |
| 405 | 398 |
| 406 session_id = htonl(msg->msnslp_header.session_id); | 399 session_id = htonl(msg->msnslp_header.session_id); |
| 407 id = htonl(msg->msnslp_header.id); | 400 id = htonl(msg->msnslp_header.id); |
| 408 offset = htonl(msg->msnslp_header.offset); | 401 offset = htonl(msg->msnslp_header.offset); |
| 409 total_size = htonl(msg->msnslp_header.total_size); | 402 total_size = htonl(msg->msnslp_header.total_size); |
| 411 flags = htonl(msg->msnslp_header.flags); | 404 flags = htonl(msg->msnslp_header.flags); |
| 412 ack_session_id = htonl(msg->msnslp_header.ack_session_id); | 405 ack_session_id = htonl(msg->msnslp_header.ack_session_id); |
| 413 ack_unique_id = htonl(msg->msnslp_header.ack_unique_id); | 406 ack_unique_id = htonl(msg->msnslp_header.ack_unique_id); |
| 414 ack_length = htonl(msg->msnslp_header.ack_length); | 407 ack_length = htonl(msg->msnslp_header.ack_length); |
| 415 | 408 |
| 416 gaim_debug_misc("msn", "cur size = %d\n", (c - msg_start)); | 409 c += msn_put32(c, session_id); |
| 417 gaim_debug_misc("msn", "msg->size = %d\n", msg->size); | 410 c += msn_put32(c, id); |
| 418 | 411 c += msn_put32(c, offset); |
| 419 c += msn_put32(c, session_id); gaim_debug_misc("msn", "1\n"); | 412 c += msn_put32(c, 0); |
| 420 c += msn_put32(c, id); gaim_debug_misc("msn", "2\n"); | 413 c += msn_put32(c, total_size); |
| 421 c += msn_put32(c, offset); gaim_debug_misc("msn", "3\n"); | 414 c += msn_put32(c, 0); |
| 422 c += msn_put32(c, 0); gaim_debug_misc("msn", "4\n"); | 415 c += msn_put32(c, length); |
| 423 c += msn_put32(c, total_size); gaim_debug_misc("msn", "5\n"); | 416 c += msn_put32(c, flags); |
| 424 c += msn_put32(c, 0); gaim_debug_misc("msn", "6\n"); | 417 c += msn_put32(c, ack_session_id); |
| 425 c += msn_put32(c, length); gaim_debug_misc("msn", "7\n"); | 418 c += msn_put32(c, ack_unique_id); |
| 426 c += msn_put32(c, flags); gaim_debug_misc("msn", "8\n"); | 419 c += msn_put32(c, ack_length); |
| 427 c += msn_put32(c, ack_session_id); gaim_debug_misc("msn", "9\n"); | 420 c += msn_put32(c, 0); |
| 428 c += msn_put32(c, ack_unique_id); gaim_debug_misc("msn", "10\n"); | |
| 429 c += msn_put32(c, ack_length); gaim_debug_misc("msn", "11\n"); | |
| 430 c += msn_put32(c, 0); gaim_debug_misc("msn", "12\n"); | |
| 431 | |
| 432 gaim_debug_misc("msn", "cur size = %d\n", (c - msg_start)); | |
| 433 gaim_debug_misc("msn", "msg->size = %d\n", msg->size); | |
| 434 | 421 |
| 435 if (body != NULL) | 422 if (body != NULL) |
| 436 { | 423 { |
| 437 strncpy(c, body, len); | 424 g_strlcpy(c, body, c - msg_start); |
| 438 | |
| 439 gaim_debug_misc("msn", "cur size = %d\n", (c - msg_start)); | |
| 440 gaim_debug_misc("msn", "msg->size = %d\n", msg->size); | |
| 441 | 425 |
| 442 c += strlen(body); | 426 c += strlen(body); |
| 443 | |
| 444 gaim_debug_misc("msn", "cur size = %d\n", (c - msg_start)); | |
| 445 gaim_debug_misc("msn", "msg->size = %d\n", msg->size); | |
| 446 | 427 |
| 447 if (strlen(body) > 0) | 428 if (strlen(body) > 0) |
| 448 *c++ = '\0'; | 429 *c++ = '\0'; |
| 449 | |
| 450 gaim_debug_misc("msn", "cur size = %d\n", (c - msg_start)); | |
| 451 gaim_debug_misc("msn", "msg->size = %d\n", msg->size); | |
| 452 } | 430 } |
| 453 | 431 |
| 454 c += msn_put32(c, msg->msnslp_footer.app_id); | 432 c += msn_put32(c, msg->msnslp_footer.app_id); |
| 455 | |
| 456 gaim_debug_misc("msn", "cur size = %d\n", (c - msg_start)); | |
| 457 gaim_debug_misc("msn", "msg->size = %d\n", msg->size); | |
| 458 | 433 |
| 459 if (msg->size != (c - msg_start)) | 434 if (msg->size != (c - msg_start)) |
| 460 { | 435 { |
| 461 gaim_debug(GAIM_DEBUG_ERROR, "msn", | 436 gaim_debug(GAIM_DEBUG_ERROR, "msn", |
| 462 "Outgoing message size (%d) and data length (%d) " | 437 "Outgoing message size (%d) and data length (%d) " |
