pidgin: f99b2d3f: Yahoo: Fix a crash that happens when the...

rekkanoryo at pidgin.im rekkanoryo at pidgin.im
Wed Dec 29 20:31:19 EST 2010


----------------------------------------------------------------------
Revision: f99b2d3f38a4c4e2371b93caa74715ee13fa81ba
Parent:   3851a1cf3c16073e17c31b6b23194cb26ce1be6f
Author:   hanzz at soc.pidgin.im
Date:     12/29/10 20:22:52
Branch:   im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/f99b2d3f38a4c4e2371b93caa74715ee13fa81ba

Changelog: 

Yahoo: Fix a crash that happens when the PurpleAccount disconnects after
purple_network_listen() is called in yahoo_send_p2p_pkt(), but before the
callback for purple_network_listen() is called.  This solution isn't perfect--
it will almost certainly fall flat on its face if yahoo_send_p2p_packet() is
called twice in a row--but doesn't make matters worse.  Fixes #12432.

Changes against parent 3851a1cf3c16073e17c31b6b23194cb26ce1be6f

  patched  ChangeLog
  patched  libpurple/protocols/yahoo/libymsg.c
  patched  libpurple/protocols/yahoo/libymsg.h

-------------- next part --------------
============================================================
--- ChangeLog	55c168b29c37554c0f1fa684b7de0c3798b32c9d
+++ ChangeLog	430c78b901aa7fd940f38bc044f92cff5de2f0d1
@@ -24,6 +24,10 @@ version 2.7.10 (??/??/????):
 	QQ:
 	* QQ2008 is now the default protocol version. (Michael Terry) (#11635)
 
+	Yahoo!/Yahoo! JAPAN:
+	* Fix a crash when an account disconnects before a p2p session is
+	  completely set up. (Jan Kaluza) (#12432)
+
 version 2.7.9 (12/26/2010):
 	MSN:
 	* Fix a crash when receiving short packets related to P2Pv2. (CVE ID
============================================================
--- libpurple/protocols/yahoo/libymsg.c	aedcc38fb75b9a99be6cb60666cd72a4e2376158
+++ libpurple/protocols/yahoo/libymsg.c	d8ad466c2c0ae5b738049a6ae6a6ccb34cd21ce2
@@ -2673,14 +2673,15 @@ static void yahoo_p2p_server_listen_cb(i
 	if(!(p2p_data = data))
 		return ;
 
+	yd = p2p_data->gc->proto_data;
+	yd->listen_data = NULL;
+
 	if(listenfd == -1) {
 		purple_debug_warning("yahoo","p2p: error starting p2p server\n");
 		yahoo_p2p_disconnect_destroy_data(data);
 		return;
 	}
 
-	yd = p2p_data->gc->proto_data;
-
 	/* Add an Input Read event to the file descriptor */
 	yd->yahoo_local_p2p_server_fd = listenfd;
 	yd->yahoo_p2p_server_watcher = purple_input_add(listenfd, PURPLE_INPUT_READ, yahoo_p2p_server_send_connected_cb,data);
@@ -2759,8 +2760,15 @@ void yahoo_send_p2p_pkt(PurpleConnection
 	p2p_data->connection_type = YAHOO_P2P_WE_ARE_SERVER;
 	p2p_data->source = -1;
 
-	/* FIXME: Shouldn't this deal with the PurpleNetworkListenData* */
-	purple_network_listen(YAHOO_PAGER_PORT_P2P, SOCK_STREAM, yahoo_p2p_server_listen_cb, p2p_data);
+	/* FIXME: If the port is already used, purple_network_listener returns NULL and old listener won't be canceled
+	 * in yahoo_close function. */
+	if (yd->listen_data)
+		purple_debug_warning("yahoo","p2p: Failed to create p2p server - server already exists\n");
+	else {
+		yd->listen_data = purple_network_listen(YAHOO_PAGER_PORT_P2P, SOCK_STREAM, yahoo_p2p_server_listen_cb, p2p_data);
+		if (yd->listen_data == NULL)
+			purple_debug_warning("yahoo","p2p: Failed to created p2p server\n");
+	}
 
 	g_free(base64_ip);
 }
@@ -3784,6 +3792,8 @@ void yahoo_close(PurpleConnection *gc) {
 		yahoo_buddy_icon_upload_data_free(yd->picture_upload_todo);
 	if (yd->ycht)
 		ycht_connection_close(yd->ycht);
+	if (yd->listen_data != NULL)
+		purple_network_listen_cancel(yd->listen_data);
 
 	g_free(yd->pending_chat_room);
 	g_free(yd->pending_chat_id);
============================================================
--- libpurple/protocols/yahoo/libymsg.h	98f98d355250b495d3e26f25e945b0ce4fd1ec7f
+++ libpurple/protocols/yahoo/libymsg.h	27cfffcdca15f0b87ff58f9e2b624a0c203fd27c
@@ -28,6 +28,7 @@
 #include "circbuffer.h"
 #include "cmds.h"
 #include "prpl.h"
+#include "network.h"
 
 #define YAHOO_PAGER_HOST_REQ_URL "http://vcs1.msg.yahoo.com/capacity"
 #define YAHOO_PAGER_HOST_FALLBACK "scsa.msg.yahoo.com"
@@ -243,6 +244,7 @@ typedef struct {
 	GSList *url_datas;
 	GHashTable *xfer_peer_idstring_map;/* Hey, i dont know, but putting this HashTable next to friends gives a run time fault... */
 	GSList *cookies;/* contains all cookies, including _y and _t */
+	PurpleNetworkListenData *listen_data;
 
 	/**
 	 * We may receive a list15 in multiple packets with no prior warning as to how many we'll be getting;


More information about the Commits mailing list