comparison libgaim/protocols/qq/file_trans.c @ 14632:108152f29f37

[gaim-migrate @ 17378] There's no reason to generate our session_md5 more than once. This probably doesn't fix the bug from Adium crash 215722, but if it happens again, it'll be a bit easier to track down. Also, I was wrong about the login scheme. Nothing significant is different, so remove the comment. committer: Tailor Script <tailor@pidgin.im>
author Mark Huetsch <markhuetsch>
date Wed, 27 Sep 2006 00:31:39 +0000
parents 6b8bc59414f0
children d1a76ccb93c4
comparison
equal deleted inserted replaced
14631:622931ca5622 14632:108152f29f37
282 /* send a file to udp channel with QQ_FILE_CONTROL_PACKET_TAG */ 282 /* send a file to udp channel with QQ_FILE_CONTROL_PACKET_TAG */
283 void qq_send_file_ctl_packet(GaimConnection *gc, guint16 packet_type, guint32 to_uid, guint8 hellobyte) 283 void qq_send_file_ctl_packet(GaimConnection *gc, guint16 packet_type, guint32 to_uid, guint8 hellobyte)
284 { 284 {
285 qq_data *qd; 285 qq_data *qd;
286 gint bytes, bytes_expected, encrypted_len; 286 gint bytes, bytes_expected, encrypted_len;
287 guint8 *raw_data, *cursor, *encrypted_data, *md5; 287 guint8 *raw_data, *cursor, *encrypted_data;
288 time_t now; 288 time_t now;
289 ft_info *info; 289 ft_info *info;
290 290
291 qd = (qq_data *) gc->proto_data; 291 qd = (qq_data *) gc->proto_data;
292 info = (ft_info *) qd->xfer->data; 292 info = (ft_info *) qd->xfer->data;
294 raw_data = g_new0 (guint8, 61); 294 raw_data = g_new0 (guint8, 61);
295 cursor = raw_data; 295 cursor = raw_data;
296 296
297 bytes = 0; 297 bytes = 0;
298 now = time(NULL); 298 now = time(NULL);
299 md5 = _gen_session_md5(qd->uid, qd->session_key); 299
300 300 bytes += create_packet_data(raw_data, &cursor, qd->session_md5, 16);
301 bytes += create_packet_data(raw_data, &cursor, md5, 16);
302 bytes += create_packet_w(raw_data, &cursor, packet_type); 301 bytes += create_packet_w(raw_data, &cursor, packet_type);
303 switch (packet_type) { 302 switch (packet_type) {
304 case QQ_FILE_CMD_SENDER_SAY_HELLO: 303 case QQ_FILE_CMD_SENDER_SAY_HELLO:
305 case QQ_FILE_CMD_SENDER_SAY_HELLO_ACK: 304 case QQ_FILE_CMD_SENDER_SAY_HELLO_ACK:
306 case QQ_FILE_CMD_RECEIVER_SAY_HELLO_ACK: 305 case QQ_FILE_CMD_RECEIVER_SAY_HELLO_ACK:
375 _qq_send_file(gc, encrypted_data, encrypted_len, QQ_FILE_CONTROL_PACKET_TAG, info->to_uid); 374 _qq_send_file(gc, encrypted_data, encrypted_len, QQ_FILE_CONTROL_PACKET_TAG, info->to_uid);
376 } 375 }
377 else 376 else
378 gaim_debug(GAIM_DEBUG_ERROR, "QQ", "qq_send_file_ctl_packet: Expected to get %d bytes, but get %d", 377 gaim_debug(GAIM_DEBUG_ERROR, "QQ", "qq_send_file_ctl_packet: Expected to get %d bytes, but get %d",
379 bytes_expected, bytes); 378 bytes_expected, bytes);
380
381 g_free(md5);
382 } 379 }
383 380
384 /* send a file to udp channel with QQ_FILE_DATA_PACKET_TAG */ 381 /* send a file to udp channel with QQ_FILE_DATA_PACKET_TAG */
385 static void _qq_send_file_data_packet(GaimConnection *gc, guint16 packet_type, guint8 sub_type, 382 static void _qq_send_file_data_packet(GaimConnection *gc, guint16 packet_type, guint8 sub_type,
386 guint32 fragment_index, guint16 seq, guint8 *data, gint len) 383 guint32 fragment_index, guint16 seq, guint8 *data, gint len)
519 gint decrypted_len; 516 gint decrypted_len;
520 qq_data *qd = (qq_data *) gc->proto_data; 517 qq_data *qd = (qq_data *) gc->proto_data;
521 guint16 packet_type; 518 guint16 packet_type;
522 guint16 seq; 519 guint16 seq;
523 guint8 hellobyte; 520 guint8 hellobyte;
524 guint8 *md5;
525 ft_info *info = (ft_info *) qd->xfer->data; 521 ft_info *info = (ft_info *) qd->xfer->data;
526 522
527 decrypted_data = g_newa(guint8, len); 523 decrypted_data = g_newa(guint8, len);
528 decrypted_len = len; 524 decrypted_len = len;
529 525
530 md5 = _gen_session_md5(qd->uid, qd->session_key); 526 if (qq_crypt(DECRYPT, cursor, len - (cursor - data), qd->session_md5, decrypted_data, &decrypted_len)) {
531 if (qq_crypt(DECRYPT, cursor, len - (cursor - data), md5, decrypted_data, &decrypted_len)) {
532 cursor = decrypted_data + 16; /* skip md5 section */ 527 cursor = decrypted_data + 16; /* skip md5 section */
533 read_packet_w(decrypted_data, &cursor, decrypted_len, &packet_type); 528 read_packet_w(decrypted_data, &cursor, decrypted_len, &packet_type);
534 read_packet_w(decrypted_data, &cursor, decrypted_len, &seq); 529 read_packet_w(decrypted_data, &cursor, decrypted_len, &seq);
535 cursor += 4+1+1+19+1; 530 cursor += 4+1+1+19+1;
536 gaim_debug(GAIM_DEBUG_INFO, "QQ", "==> [%d] receive %s packet\n", seq, qq_get_file_cmd_desc(packet_type)); 531 gaim_debug(GAIM_DEBUG_INFO, "QQ", "==> [%d] receive %s packet\n", seq, qq_get_file_cmd_desc(packet_type));
575 break; 570 break;
576 default: 571 default:
577 gaim_debug(GAIM_DEBUG_INFO, "QQ", "unprocess file command %d\n", packet_type); 572 gaim_debug(GAIM_DEBUG_INFO, "QQ", "unprocess file command %d\n", packet_type);
578 } 573 }
579 } 574 }
580 g_free(md5);
581 } 575 }
582 576
583 static void _qq_recv_file_progess(GaimConnection *gc, guint8 *buffer, guint16 len, guint32 index, guint32 offset) 577 static void _qq_recv_file_progess(GaimConnection *gc, guint8 *buffer, guint16 len, guint32 index, guint32 offset)
584 { 578 {
585 qq_data *qd = (qq_data *) gc->proto_data; 579 qq_data *qd = (qq_data *) gc->proto_data;