Mercurial > pidgin
changeset 14656:d1a76ccb93c4
[gaim-migrate @ 17402]
leak-be-gone
committer: Tailor Script <tailor@pidgin.im>
author | Mark Huetsch <markhuetsch> |
---|---|
date | Sat, 30 Sep 2006 00:14:00 +0000 |
parents | 4764c501fdb9 |
children | 38d1052611bc |
files | libgaim/protocols/qq/char_conv.c libgaim/protocols/qq/file_trans.c libgaim/protocols/qq/group_im.c libgaim/protocols/qq/group_network.c libgaim/protocols/qq/im.c libgaim/protocols/qq/login_logout.c libgaim/protocols/qq/recv_core.c |
diffstat | 7 files changed, 48 insertions(+), 25 deletions(-) [+] |
line wrap: on
line diff
--- a/libgaim/protocols/qq/char_conv.c Fri Sep 29 20:49:33 2006 +0000 +++ b/libgaim/protocols/qq/char_conv.c Sat Sep 30 00:14:00 2006 +0000 @@ -112,10 +112,10 @@ if (error == NULL) return ret; /* conversion is OK */ else { /* conversion error */ + gchar *failed = hex_dump_to_str((guint8 *) str, (len == -1) ? strlen(str) : len); gaim_debug(GAIM_DEBUG_ERROR, "QQ", "%s\n", error->message); - gaim_debug(GAIM_DEBUG_WARNING, "QQ", - "Dump failed text\n%s", - hex_dump_to_str((guint8 *) str, (len == -1) ? strlen(str) : len)); + gaim_debug(GAIM_DEBUG_WARNING, "QQ", "Dump failed text\n%s", failed); + g_free(failed); g_error_free(error); return g_strdup(QQ_NULL_MSG); }
--- a/libgaim/protocols/qq/file_trans.c Fri Sep 29 20:49:33 2006 +0000 +++ b/libgaim/protocols/qq/file_trans.c Sat Sep 30 00:14:00 2006 +0000 @@ -344,26 +344,29 @@ } if (bytes == bytes_expected) { - gaim_debug(GAIM_DEBUG_INFO, "QQ", "sending packet[%s]: \n%s", qq_get_file_cmd_desc(packet_type), - hex_dump_to_str(raw_data, bytes)); + gchar *hex_dump = hex_dump_to_str(raw_data, bytes); + gaim_debug(GAIM_DEBUG_INFO, "QQ", "sending packet[%s]: \n%s", qq_get_file_cmd_desc(packet_type), hex_dump); + g_free(hex_dump); encrypted_len = bytes + 16; encrypted_data = g_newa(guint8, encrypted_len); qq_crypt(ENCRYPT, raw_data, bytes, info->file_session_key, encrypted_data, &encrypted_len); /*debug: try to decrypt it */ /* if (QQ_DEBUG) { - gaim_debug(GAIM_DEBUG_INFO, "QQ", "encrypted packet: \n%s", - hex_dump_to_str(encrypted_data, encrypted_len)); guint8 *buf; int buflen; + hex_dump = hex_dump_to_str(encrypted_data, encrypted_len); + gaim_debug(GAIM_DEBUG_INFO, "QQ", "encrypted packet: \n%s", hex_dump); + g_free(hex_dump); buf = g_newa(guint8, MAX_PACKET_SIZE); buflen = encrypted_len; if (qq_crypt(DECRYPT, encrypted_data, encrypted_len, info->file_session_key, buf, &buflen)) { gaim_debug(GAIM_DEBUG_INFO, "QQ", "decrypt success\n"); if (buflen == bytes && memcmp(raw_data, buf, buflen) == 0) gaim_debug(GAIM_DEBUG_INFO, "QQ", "checksum ok\n"); - gaim_debug(GAIM_DEBUG_INFO, "QQ", "decrypted packet: \n%s", - hex_dump_to_str(buf, buflen)); + hex_dump = hex_dump_to_str(buf, buflen); + gaim_debug(GAIM_DEBUG_INFO, "QQ", "decrypted packet: \n%s", hex_dump); + g_free(hex_dump); } else { gaim_debug(GAIM_DEBUG_INFO, "QQ", "decrypt fail\n"); } @@ -524,13 +527,15 @@ decrypted_len = len; if (qq_crypt(DECRYPT, cursor, len - (cursor - data), qd->session_md5, decrypted_data, &decrypted_len)) { + gchar *hex_dump; cursor = decrypted_data + 16; /* skip md5 section */ read_packet_w(decrypted_data, &cursor, decrypted_len, &packet_type); read_packet_w(decrypted_data, &cursor, decrypted_len, &seq); cursor += 4+1+1+19+1; gaim_debug(GAIM_DEBUG_INFO, "QQ", "==> [%d] receive %s packet\n", seq, qq_get_file_cmd_desc(packet_type)); - gaim_debug(GAIM_DEBUG_INFO, "QQ", "decrypted control packet received: \n%s", - hex_dump_to_str(decrypted_data, decrypted_len)); + hex_dump = hex_dump_to_str(decrypted_data, decrypted_len); + gaim_debug(GAIM_DEBUG_INFO, "QQ", "decrypted control packet received: \n%s", hex_dump); + g_free(hex_dump); switch (packet_type) { case QQ_FILE_CMD_NOTIFY_IP_ACK: cursor = decrypted_data;
--- a/libgaim/protocols/qq/group_im.c Fri Sep 29 20:49:33 2006 +0000 +++ b/libgaim/protocols/qq/group_im.c Sat Sep 30 00:14:00 2006 +0000 @@ -299,7 +299,7 @@ void qq_process_recv_group_im(guint8 *data, guint8 **cursor, gint data_len, guint32 internal_group_id, GaimConnection *gc, guint16 im_type) { - gchar *msg_with_gaim_smiley, *msg_utf8_encoded, *im_src_name; + gchar *msg_with_gaim_smiley, *msg_utf8_encoded, *im_src_name, *hex_dump; guint16 unknown; guint32 unknown4; GaimConversation *conv; @@ -312,8 +312,8 @@ g_return_if_fail(data != NULL && data_len > 0); qd = (qq_data *) gc->proto_data; - gaim_debug(GAIM_DEBUG_INFO, "QQ", - "group im hex dump\n%s\n", hex_dump_to_str(*cursor, data_len - (*cursor - data))); + hex_dump = hex_dump_to_str(*cursor, data_len - (*cursor - data)); + gaim_debug(GAIM_DEBUG_INFO, "QQ", "group im hex dump\n%s\n", hex_dump); if (*cursor >= (data + data_len - 1)) { gaim_debug(GAIM_DEBUG_WARNING, "QQ", "Received group im_group is empty\n"); @@ -399,6 +399,7 @@ (conv)), im_src_name, 0, msg_utf8_encoded, im_group->send_time); g_free(im_src_name); } + g_free(hex_dump); g_free(msg_with_gaim_smiley); g_free(msg_utf8_encoded); g_free(im_group->msg);
--- a/libgaim/protocols/qq/group_network.c Fri Sep 29 20:49:33 2006 +0000 +++ b/libgaim/protocols/qq/group_network.c Sat Sep 30 00:14:00 2006 +0000 @@ -94,8 +94,12 @@ /* default process, dump only */ static void _qq_process_group_cmd_reply_default(guint8 *data, guint8 **cursor, gint len, GaimConnection *gc) { + gchar *hex_dump; g_return_if_fail(data != NULL && len > 0); - gaim_debug(GAIM_DEBUG_INFO, "QQ", "Dump unprocessed group cmd reply:\n%s", hex_dump_to_str(data, len)); + + hex_dump = hex_dump_to_str(data, len); + gaim_debug(GAIM_DEBUG_INFO, "QQ", "Dump unprocessed group cmd reply:\n%s", hex_dump); + g_free(hex_dump); } /* The lower layer command of send group cmd */
--- a/libgaim/protocols/qq/im.c Fri Sep 29 20:49:33 2006 +0000 +++ b/libgaim/protocols/qq/im.c Sat Sep 30 00:14:00 2006 +0000 @@ -327,6 +327,7 @@ gint bytes; qq_recv_normal_im_common *common; qq_recv_normal_im_unprocessed *im_unprocessed; + gchar *hex_dump; g_return_if_fail (data != NULL && len != 0); @@ -384,10 +385,9 @@ gaim_debug (GAIM_DEBUG_WARNING, "QQ", "Normal IM, unprocessed type [0x%04x]\n", common->normal_im_type); - gaim_debug (GAIM_DEBUG_WARNING, "QQ", - "Dump unknown part.\n%s", - hex_dump_to_str (im_unprocessed->unknown, - im_unprocessed->length)); + hex_dump = hex_dump_to_str(im_unprocessed->unknown, im_unprocessed->length); + gaim_debug (GAIM_DEBUG_WARNING, "QQ", "Dump unknown part.\n%s", hex_dump); + g_free(hex_dump); g_free (common->session_md5); return; }
--- a/libgaim/protocols/qq/login_logout.c Fri Sep 29 20:49:33 2006 +0000 +++ b/libgaim/protocols/qq/login_logout.c Sat Sep 30 00:14:00 2006 +0000 @@ -377,6 +377,7 @@ void qq_process_request_login_token_reply(guint8 *buf, gint buf_len, GaimConnection *gc) { qq_data *qd; + gchar *hex_dump; g_return_if_fail(buf != NULL && buf_len != 0); @@ -389,17 +390,20 @@ gaim_debug(GAIM_DEBUG_INFO, "QQ", "Attempting to proceed with the actual packet length.\n"); } + hex_dump = hex_dump_to_str(buf+2, buf_len-2); gaim_debug(GAIM_DEBUG_INFO, "QQ", - "<<< got a token with %d bytes -> [default] decrypt and dump\n%s",buf_len-2, hex_dump_to_str(buf+2, buf_len-2)); + "<<< got a token with %d bytes -> [default] decrypt and dump\n%s", buf_len-2, hex_dump); qq_send_packet_login(gc, buf_len-2, buf+2); } else { gaim_debug(GAIM_DEBUG_ERROR, "QQ", "Unknown request login token reply code : %d\n", buf[0]); + hex_dump = hex_dump_to_str(buf, buf_len); gaim_debug(GAIM_DEBUG_WARNING, "QQ", ">>> %d bytes -> [default] decrypt and dump\n%s", - buf_len, hex_dump_to_str(buf, buf_len)); + buf_len, hex_dump); try_dump_as_gbk(buf, buf_len); gaim_connection_error(gc, _("Request login token error!")); } + g_free(hex_dump); } /* send logout packets to QQ server */ @@ -421,6 +425,7 @@ gint len, ret, bytes; guint8 *data; qq_data *qd; + gchar *hex_dump; g_return_if_fail(buf != NULL && buf_len != 0); @@ -453,9 +458,11 @@ break; default: gaim_debug(GAIM_DEBUG_ERROR, "QQ", "Unknown reply code: %d\n", data[0]); + hex_dump = hex_dump_to_str(data, len); gaim_debug(GAIM_DEBUG_WARNING, "QQ", ">>> %d bytes -> [default] decrypt and dump\n%s", - buf_len, hex_dump_to_str(data, len)); + buf_len, hex_dump); + g_free(hex_dump); try_dump_as_gbk(data, len); ret = QQ_LOGIN_REPLY_MISC_ERROR;
--- a/libgaim/protocols/qq/recv_core.c Fri Sep 29 20:49:33 2006 +0000 +++ b/libgaim/protocols/qq/recv_core.c Sat Sep 30 00:14:00 2006 +0000 @@ -90,9 +90,11 @@ _qq_show_packet("Processing unknown packet", buf, len); if (qq_crypt(DECRYPT, buf, buf_len, qd->session_key, data, &len)) { + gchar *hex_dump = hex_dump_to_str(data, len); gaim_debug(GAIM_DEBUG_WARNING, "QQ", ">>> [%d] %s, %d bytes -> [default] decrypt and dump\n%s", - seq, qq_get_cmd_desc(cmd), buf_len, hex_dump_to_str(data, len)); + seq, qq_get_cmd_desc(cmd), buf_len, hex_dump); + g_free(hex_dump); try_dump_as_gbk(data, len); } else { gaim_debug(GAIM_DEBUG_ERROR, "QQ", "Fail decrypt packet with default process\n"); @@ -115,8 +117,10 @@ bytes_expected = qd->use_tcp ? QQ_TCP_HEADER_LENGTH : QQ_UDP_HEADER_LENGTH; if (buf_len < bytes_expected) { + gchar *hex_dump = hex_dump_to_str(buf, buf_len); gaim_debug(GAIM_DEBUG_ERROR, - "QQ", "Received packet is too short, dump and drop\n%s", hex_dump_to_str(buf, buf_len)); + "QQ", "Received packet is too short, dump and drop\n%s", hex_dump); + g_free(hex_dump); return; } /* initialize */ @@ -149,8 +153,10 @@ } if ((buf[buf_len - 1] != QQ_PACKET_TAIL) || (header.header_tag != QQ_PACKET_TAG)) { + gchar *hex_dump = hex_dump_to_str(buf, buf_len); gaim_debug(GAIM_DEBUG_ERROR, - "QQ", "Unknown QQ proctocol, dump and drop\n%s", hex_dump_to_str(buf, buf_len)); + "QQ", "Unknown QQ proctocol, dump and drop\n%s", hex_dump); + g_free(hex_dump); return; }