pidgin: 904144db: oscar: Fix a race condition that leads t...

darkrain42 at pidgin.im darkrain42 at pidgin.im
Mon Feb 22 13:05:45 EST 2010


-----------------------------------------------------------------
Revision: 904144db35079f8cc320a0380de5c1a1df95a436
Ancestor: 9484d318c55139eed1c1919a2e793af4bab3b9e5
Author: darkrain42 at pidgin.im
Date: 2010-02-22T17:53:38
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/904144db35079f8cc320a0380de5c1a1df95a436

Modified files:
        libpurple/protocols/oscar/flap_connection.c

ChangeLog: 

oscar: Fix a race condition that leads to a crash.

With SSL enabled, if we start connecting and something calls
purple_account_disconnect between when an SSL flap connection is started
and when the connection is actually established, it isn't properly
cleaned up (and we try to close the flap), which leads to free-after-use.
You can simulate this by adding a timeout-triggered disconnect to the
end of oscar_connect_to_bos.

[02/22/10 17:11:51] <libpurple/oscar> Destroying oscar connection of type 0x0002.  Disconnect reason is 0
[02/22/10 17:11:51] <libpurple/oscar> Disconnected.  Code is 0x0000 and msg is

(hiicq:17126): GLib-WARNING **: giounix.c:400Error while getting flags for FD: Bad file descriptor (9)

[02/22/10 17:11:51] <libpurple/oscar> Scheduling destruction of FLAP connection of type 0x0002
[02/22/10 17:11:51] <libpurple/oscar> Signed off.
...
[02/22/10 17:11:51] <libpurple/oscar> Destroying oscar connection of type 0x7261.  Disconnect reason is 1668179315

-------------- next part --------------
============================================================
--- libpurple/protocols/oscar/flap_connection.c	19e7d70825751cca88fab282dd601e81835d4146
+++ libpurple/protocols/oscar/flap_connection.c	8832cd5983913c675765f2e1f3034344d2e29467
@@ -364,6 +364,12 @@ flap_connection_close(OscarData *od, Fla
 		conn->connect_data = NULL;
 	}
 
+	if (conn->gsc != NULL && conn->gsc->connect_data != NULL)
+	{
+		purple_ssl_close(conn->gsc);
+		conn->gsc = NULL;
+	}
+
 	if (conn->new_conn_data != NULL)
 	{
 		if (conn->type == SNAC_FAMILY_CHAT)


More information about the Commits mailing list