pidgin: e337f545: Make checking of p2p packet with invalid...

sulabh at soc.pidgin.im sulabh at soc.pidgin.im
Sat Oct 24 04:00:49 EDT 2009


-----------------------------------------------------------------
Revision: e337f54571438969f9ea52701d74b4e0f19968ef
Ancestor: ec6291ec02cfa2c94de6aedf7b94c48385ac65ef
Author: sulabh at soc.pidgin.im
Date: 2009-10-24T04:40:51
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/e337f54571438969f9ea52701d74b4e0f19968ef

Modified files:
        libpurple/protocols/yahoo/libymsg.c

ChangeLog: 

Make checking of p2p packet with invalid id per IM instead of per packet. 

-------------- next part --------------
============================================================
--- libpurple/protocols/yahoo/libymsg.c	f7d613e8962e7f16832782661126d33a897d7c1b
+++ libpurple/protocols/yahoo/libymsg.c	5585148092a52df994ccd3f526694a3c3b8e7d8d
@@ -952,7 +952,6 @@ static void yahoo_process_message(Purple
 	GSList *list = NULL;
 	struct _yahoo_im *im = NULL;
 	const char *imv = NULL;
-	gint val_11 = 0;
 
 	account = purple_connection_get_account(gc);
 
@@ -1006,9 +1005,18 @@ static void yahoo_process_message(Purple
 					
 			}
 			/* peer session id */
-			if (pair->key == 11) {
-				if (im)
-					val_11 = strtol(pair->value, NULL, 10);
+			if (im && (pair->key == 11)) {
+				/* disconnect the peer if connected through p2p and sends wrong value for session id */
+				if( (im->fed == YAHOO_FEDERATION_NONE) && (pkt_type == YAHOO_PKT_TYPE_P2P) 
+						&& (yd->session_id != strtol(pair->value, NULL, 10)) )
+				{
+					purple_debug_warning("yahoo","p2p: %s sent us message with wrong session id. Disconnecting p2p connection to peer\n", im->fed_from);
+					/* remove from p2p connection lists, also calls yahoo_p2p_disconnect_destroy_data */
+					g_hash_table_remove(yd->peers, im->fed_from);
+					g_free(im->fed_from);
+					g_free(im);
+					return; /* Not sure whether we should process remaining IMs in this packet */
+				}
 			}
 			/* IMV key */
 			if (pair->key == 63)
@@ -1025,20 +1033,9 @@ static void yahoo_process_message(Purple
 		                  _("Your Yahoo! message did not get sent."), NULL);
 	}
 
-	/* disconnect the peer if connected through p2p and sends wrong value for session id */
-	if( (pkt_type == YAHOO_PKT_TYPE_P2P) && (val_11 != yd->session_id) ) {
-		purple_debug_warning("yahoo","p2p: %s sent us message with wrong session id. Disconnecting p2p connection to peer\n", im ? im->fed_from : "(im was null)");
-		/* remove from p2p connection lists, also calls yahoo_p2p_disconnect_destroy_data */
-		if (im) {
-			g_hash_table_remove(yd->peers, im->fed_from);
-			g_free(im);
-		}
-		return;
-	}
-
 	/* TODO: It seems that this check should be per IM, not global */
 	/* Check for the Doodle IMV */
-	/* no doodle with federated buddies -- assumption???  */
+	/* no doodle with federated buddies */
 	if (im != NULL && imv!= NULL && im->from != NULL)
 	{
 		g_hash_table_replace(yd->imvironments, g_strdup(im->from), g_strdup(imv));


More information about the Commits mailing list