diff libpurple/protocols/yahoo/yahoo_filexfer.c @ 30644:d0b0f0d17046

Fix Yahoo file transfers that get stuck saying \"Waiting for transfer to begin\". The IP address and its parts should be unsigned. Also, this math was a bit too complicated. Integer division means we don't need to care about the fractional part. Fixes #12213.
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Tue, 22 Jun 2010 05:30:36 +0000
parents 3c9534e77ea1
children 76b2a2636c62 351d07aefb09
line wrap: on
line diff
--- a/libpurple/protocols/yahoo/yahoo_filexfer.c	Tue Jun 22 01:40:18 2010 +0000
+++ b/libpurple/protocols/yahoo/yahoo_filexfer.c	Tue Jun 22 05:30:36 2010 +0000
@@ -983,8 +983,8 @@
 	struct yahoo_xfer_data *xd;
 	struct sockaddr_in *addr;
 	struct yahoo_packet *pkt;
-	long actaddr;
-	long a,b,c,d;
+	unsigned long actaddr;
+	unsigned char a,b,c,d;
 	PurpleConnection *gc;
 	PurpleAccount *account;
 	YahooData *yd;
@@ -1018,19 +1018,19 @@
 	/* TODO:actually, u must try with addr no.1 , if its not working addr no.2 ..... */
 	addr = hosts->data;
 	actaddr = addr->sin_addr.s_addr;
-	d = actaddr % 256;
-	actaddr = (actaddr - d) / 256;
-	c = actaddr % 256;
-	actaddr = (actaddr - c) / 256;
-	b = actaddr % 256;
-	actaddr = (actaddr - b) / 256;
-	a = actaddr;
+	d = actaddr & 0xff;
+	actaddr >>= 8;
+	c = actaddr & 0xff;
+	actaddr >>= 8;
+	b = actaddr & 0xff;
+	actaddr >>= 8;
+	a = actaddr & 0xff;
 	if(yd->jp)
 		xd->port = YAHOOJP_XFER_RELAY_PORT;
 	else
 		xd->port = YAHOO_XFER_RELAY_PORT;
 
-	url = g_strdup_printf("%ld.%ld.%ld.%ld", d, c, b, a);
+	url = g_strdup_printf("%u.%u.%u.%u", d, c, b, a);
 
 	/* Free the address... */
 	g_free(hosts->data);