comparison libgaim/protocols/qq/login_logout.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
169 bytes += QQ_KEY_LENGTH; 169 bytes += QQ_KEY_LENGTH;
170 gaim_debug(GAIM_DEBUG_INFO, "QQ", "Get session_key done\n"); 170 gaim_debug(GAIM_DEBUG_INFO, "QQ", "Get session_key done\n");
171 /* 017-020: login uid */ 171 /* 017-020: login uid */
172 bytes += read_packet_dw(data, &cursor, len, &lrop.uid); 172 bytes += read_packet_dw(data, &cursor, len, &lrop.uid);
173 /* 021-024: server detected user public IP */ 173 /* 021-024: server detected user public IP */
174 bytes += read_packet_data(data, &cursor, len, (guint8 *) & lrop.client_ip, 4); 174 bytes += read_packet_data(data, &cursor, len, (guint8 *) &lrop.client_ip, 4);
175 /* 025-026: server detected user port */ 175 /* 025-026: server detected user port */
176 bytes += read_packet_w(data, &cursor, len, &lrop.client_port); 176 bytes += read_packet_w(data, &cursor, len, &lrop.client_port);
177 /* 027-030: server detected itself ip 127.0.0.1 ? */ 177 /* 027-030: server detected itself ip 127.0.0.1 ? */
178 bytes += read_packet_data(data, &cursor, len, (guint8 *) & lrop.server_ip, 4); 178 bytes += read_packet_data(data, &cursor, len, (guint8 *) &lrop.server_ip, 4);
179 /* 031-032: server listening port */ 179 /* 031-032: server listening port */
180 bytes += read_packet_w(data, &cursor, len, &lrop.server_port); 180 bytes += read_packet_w(data, &cursor, len, &lrop.server_port);
181 /* 033-036: login time for current session */ 181 /* 033-036: login time for current session */
182 bytes += read_packet_dw(data, &cursor, len, (guint32 *) & lrop.login_time); 182 bytes += read_packet_dw(data, &cursor, len, (guint32 *) &lrop.login_time);
183 /* 037-062: 26 bytes, unknown */ 183 /* 037-062: 26 bytes, unknown */
184 bytes += read_packet_data(data, &cursor, len, (guint8 *) & lrop.unknown1, 26); 184 bytes += read_packet_data(data, &cursor, len, (guint8 *) &lrop.unknown1, 26);
185 /* 063-066: unknown server1 ip address */ 185 /* 063-066: unknown server1 ip address */
186 bytes += read_packet_data(data, &cursor, len, (guint8 *) & lrop.unknown_server1_ip, 4); 186 bytes += read_packet_data(data, &cursor, len, (guint8 *) &lrop.unknown_server1_ip, 4);
187 /* 067-068: unknown server1 port */ 187 /* 067-068: unknown server1 port */
188 bytes += read_packet_w(data, &cursor, len, &lrop.unknown_server1_port); 188 bytes += read_packet_w(data, &cursor, len, &lrop.unknown_server1_port);
189 /* 069-072: unknown server2 ip address */ 189 /* 069-072: unknown server2 ip address */
190 bytes += read_packet_data(data, &cursor, len, (guint8 *) & lrop.unknown_server2_ip, 4); 190 bytes += read_packet_data(data, &cursor, len, (guint8 *) &lrop.unknown_server2_ip, 4);
191 /* 073-074: unknown server2 port */ 191 /* 073-074: unknown server2 port */
192 bytes += read_packet_w(data, &cursor, len, &lrop.unknown_server2_port); 192 bytes += read_packet_w(data, &cursor, len, &lrop.unknown_server2_port);
193 /* 075-076: 2 bytes unknown */ 193 /* 075-076: 2 bytes unknown */
194 bytes += read_packet_w(data, &cursor, len, &lrop.unknown2); 194 bytes += read_packet_w(data, &cursor, len, &lrop.unknown2);
195 /* 077-078: 2 bytes unknown */ 195 /* 077-078: 2 bytes unknown */
196 bytes += read_packet_w(data, &cursor, len, &lrop.unknown3); 196 bytes += read_packet_w(data, &cursor, len, &lrop.unknown3);
197 /* 079-110: 32 bytes unknown */ 197 /* 079-110: 32 bytes unknown */
198 bytes += read_packet_data(data, &cursor, len, (guint8 *) & lrop.unknown4, 32); 198 bytes += read_packet_data(data, &cursor, len, (guint8 *) &lrop.unknown4, 32);
199 /* 111-122: 12 bytes unknown */ 199 /* 111-122: 12 bytes unknown */
200 bytes += read_packet_data(data, &cursor, len, (guint8 *) & lrop.unknown5, 12); 200 bytes += read_packet_data(data, &cursor, len, (guint8 *) &lrop.unknown5, 12);
201 /* 123-126: login IP of last session */ 201 /* 123-126: login IP of last session */
202 bytes += read_packet_data(data, &cursor, len, (guint8 *) & lrop.last_client_ip, 4); 202 bytes += read_packet_data(data, &cursor, len, (guint8 *) &lrop.last_client_ip, 4);
203 /* 127-130: login time of last session */ 203 /* 127-130: login time of last session */
204 bytes += read_packet_dw(data, &cursor, len, (guint32 *) & lrop.last_login_time); 204 bytes += read_packet_dw(data, &cursor, len, (guint32 *) &lrop.last_login_time);
205 /* 131-138: 8 bytes unknown */ 205 /* 131-138: 8 bytes unknown */
206 bytes += read_packet_data(data, &cursor, len, (guint8 *) & lrop.unknown6, 8); 206 bytes += read_packet_data(data, &cursor, len, (guint8 *) &lrop.unknown6, 8);
207 207
208 if (bytes != QQ_LOGIN_REPLY_OK_PACKET_LEN) { /* fail parsing login info */ 208 if (bytes != QQ_LOGIN_REPLY_OK_PACKET_LEN) { /* fail parsing login info */
209 gaim_debug(GAIM_DEBUG_WARNING, "QQ", 209 gaim_debug(GAIM_DEBUG_WARNING, "QQ",
210 "Fail parsing login info, expect %d bytes, read %d bytes\n", 210 "Fail parsing login info, expect %d bytes, read %d bytes\n",
211 QQ_LOGIN_REPLY_OK_PACKET_LEN, bytes); 211 QQ_LOGIN_REPLY_OK_PACKET_LEN, bytes);
212 } /* but we still go on as login OK */ 212 } /* but we still go on as login OK */
213 213
214 qd->session_key = g_memdup(lrop.session_key, QQ_KEY_LENGTH); 214 qd->session_key = lrop.session_key;
215 qd->session_md5 = _gen_session_md5(qd->uid, qd->session_key);
215 qd->my_ip = gen_ip_str(lrop.client_ip); 216 qd->my_ip = gen_ip_str(lrop.client_ip);
216 qd->my_port = lrop.client_port; 217 qd->my_port = lrop.client_port;
217 qd->login_time = lrop.login_time; 218 qd->login_time = lrop.login_time;
218 qd->last_login_time = lrop.last_login_time; 219 qd->last_login_time = lrop.last_login_time;
219 qd->last_login_ip = gen_ip_str(lrop.last_client_ip); 220 qd->last_login_ip = gen_ip_str(lrop.last_client_ip);
220
221 g_free(lrop.session_key);
222 221
223 gaim_connection_set_state(gc, GAIM_CONNECTED); 222 gaim_connection_set_state(gc, GAIM_CONNECTED);
224 qd->logged_in = TRUE; /* must be defined after sev_finish_login */ 223 qd->logged_in = TRUE; /* must be defined after sev_finish_login */
225 224
226 /* now initiate QQ Qun, do it first as it may take longer to finish */ 225 /* now initiate QQ Qun, do it first as it may take longer to finish */
277 276
278 return ret; 277 return ret;
279 } 278 }
280 279
281 /* process login reply which says wrong password */ 280 /* process login reply which says wrong password */
282 static gint _qq_process_login_wrong_pwd(GaimConnection * gc, guint8 * data, gint len) 281 static gint _qq_process_login_wrong_pwd(GaimConnection *gc, guint8 *data, gint len)
283 { 282 {
284 gchar *server_reply, *server_reply_utf8; 283 gchar *server_reply, *server_reply_utf8;
285 server_reply = g_new0(gchar, len); 284 server_reply = g_new0(gchar, len);
286 g_memmove(server_reply, data + 1, len - 1); 285 g_memmove(server_reply, data + 1, len - 1);
287 server_reply_utf8 = qq_to_utf8(server_reply, QQ_CHARSET_DEFAULT); 286 server_reply_utf8 = qq_to_utf8(server_reply, QQ_CHARSET_DEFAULT);
313 if (bytes == (cursor - buf)) /* packet creation OK */ 312 if (bytes == (cursor - buf)) /* packet creation OK */
314 _qq_send_packet(gc, buf, bytes, QQ_CMD_REQUEST_LOGIN_TOKEN); 313 _qq_send_packet(gc, buf, bytes, QQ_CMD_REQUEST_LOGIN_TOKEN);
315 else 314 else
316 gaim_debug(GAIM_DEBUG_ERROR, "QQ", "Fail create request login token packet\n"); 315 gaim_debug(GAIM_DEBUG_ERROR, "QQ", "Fail create request login token packet\n");
317 } 316 }
318
319 /* TODO: The login packet and its response have changed by QQ2006 Beta2. In that version,
320 * the login OK response packet does not appear to be decryptable with qd->pwkey or qd->inikey.
321 * Fortunately, this older system still works. */
322 317
323 /* send login packet to QQ server */ 318 /* send login packet to QQ server */
324 static void qq_send_packet_login(GaimConnection *gc, guint8 token_length, guint8 *token) 319 static void qq_send_packet_login(GaimConnection *gc, guint8 token_length, guint8 *token)
325 { 320 {
326 qq_data *qd; 321 qq_data *qd;