changeset 32503:0f1367d534a6

Move this check up a level so that it affects direct connections, too. I think this will fix the crash reported in http://trac.adium.im/ticket/15839 Still not sure why ip_atoi fails here.
author Mark Doliner <mark@kingant.net>
date Mon, 13 Feb 2012 03:19:08 +0000
parents 967354280e86
children 1c6d228d8ef9
files libpurple/protocols/oscar/peer.c
diffstat 1 files changed, 19 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/oscar/peer.c	Mon Feb 13 03:11:11 2012 +0000
+++ b/libpurple/protocols/oscar/peer.c	Mon Feb 13 03:19:08 2012 +0000
@@ -656,6 +656,7 @@
 	char *tmp;
 	FlapConnection *bos_conn;
 	const char *listener_ip;
+	const guchar *ip_atoi;
 	unsigned short listener_port;
 
 	conn = data;
@@ -690,11 +691,28 @@
 		listener_ip = purple_network_get_my_ip(bos_conn->gsc->fd);
 	else
 		listener_ip = purple_network_get_my_ip(bos_conn->fd);
+
+	ip_atoi = purple_network_ip_atoi(listener_ip);
+	if (ip_atoi == NULL) {
+		/* Could not convert IP to 4 byte array--weird, but this does
+		   happen for some users (#4829, Adium #15839).  Maybe they're
+		   connecting with IPv6...?  Maybe through a proxy? */
+		purple_debug_error("oscar", "Can't ask peer to connect to us "
+				"because purple_network_ip_atoi(%s) returned NULL. "
+				"fd=%d. is_ssl=%d\n",
+				listener_ip ? listener_ip : "(null)",
+				bos_conn->gsc ? bos_conn->gsc->fd : bos_conn->fd,
+				bos_conn->gsc ? 1 : 0);
+		peer_connection_trynext(conn);
+		return;
+	}
+
 	listener_port = purple_network_get_port_from_fd(conn->listenerfd);
+
 	if (conn->type == OSCAR_CAPABILITY_DIRECTIM)
 	{
 		aim_im_sendch2_odc_requestdirect(od,
-				conn->cookie, conn->bn, purple_network_ip_atoi(listener_ip),
+				conn->cookie, conn->bn, ip_atoi,
 				listener_port, ++conn->lastrequestnumber);
 
 		/* Print a message to a local conversation window */
@@ -706,17 +724,6 @@
 	}
 	else if (conn->type == OSCAR_CAPABILITY_SENDFILE)
 	{
-		const guchar *ip_atoi = purple_network_ip_atoi(listener_ip);
-		if (ip_atoi == NULL) {
-			purple_debug_error("oscar", "Can't ask peer to connect to us "
-					"because purple_network_ip_atoi(%s) returned NULL. "
-					"fd=%d. is_ssl=%d\n",
-					listener_ip ? listener_ip : "(null)",
-					bos_conn->gsc ? bos_conn->gsc->fd : bos_conn->fd,
-					bos_conn->gsc ? 1 : 0);
-			peer_connection_trynext(conn);
-			return;
-		}
 		aim_im_sendch2_sendfile_requestdirect(od,
 				conn->cookie, conn->bn,
 				ip_atoi,