cpw.malu.xmpp.jingle_ft: 506e8b5b: Make sure this implementation got all th...

darkrain42 at pidgin.im darkrain42 at pidgin.im
Thu May 6 15:55:21 EDT 2010


-----------------------------------------------------------------
Revision: 506e8b5bf584269937e052d01ab971948177d95e
Ancestor: 8edd40ff9d29b7707182311439f25c0e8e52c802
Author: darkrain42 at pidgin.im
Date: 2010-05-06T19:51:45
Branch: im.pidgin.cpw.malu.xmpp.jingle_ft
URL: http://d.pidgin.im/viewmtn/revision/info/506e8b5bf584269937e052d01ab971948177d95e

Modified files:
        libpurple/protocols/jabber/socks5.c

ChangeLog: 

Make sure this implementation got all the fixes from the si.c code

-------------- next part --------------
============================================================
--- libpurple/protocols/jabber/socks5.c	66f50e5ae1872036c7c6f695ddad418a5f20aa14
+++ libpurple/protocols/jabber/socks5.c	6bafd48c11e0c8a2b2743f4a411d87e2fe08b8d0
@@ -119,12 +119,14 @@ jabber_socks5_send_read_again_cb(gpointe
 			priv->error_cb(priv->user_data);
 		return;
 	} else if (priv->rxlen - 5 <  priv->rxqueue[4] + 2) {
+		/* Upper bound of 257 (priv->rxlen = 5, priv->rxqueue[4] = 0xFF) */
+		unsigned short to_read = priv->rxqueue[4] + 2 - (priv->rxlen - 5);
 		purple_debug_info("jabber-socks5", 
 			"reading %d "
-		    " bytes for DST.ADDR + port num (trying to read %" G_GSIZE_FORMAT " now)\n",
+		    " bytes for DST.ADDR + port num (trying to read %hu now)\n",
 			priv->rxqueue[4] + 2,
-			priv->rxqueue[4] + 2 - (priv->rxlen - 5));
-		len = read(source, buffer, priv->rxqueue[4] + 2 - (priv->rxlen - 5));
+			to_read);
+		len = read(source, buffer, to_read);
 
 		if (len < 0 && errno == EAGAIN)
 			return;
@@ -277,11 +279,12 @@ jabber_socks5_send_read_cb(gpointer data
 		priv->rxlen += len;
 		return;
 	} else if (priv->rxlen - 2 < priv->rxqueue[1]) {
+		/* Has a maximum value of 255 (priv->rxlen = 2, priv->rxqueue[1] = 0xFF) */
+		unsigned short to_read = priv->rxqueue[1] - (priv->rxlen - 2);
 		purple_debug_info("jabber-socks5", 
-			"reading %d "
-		    " bytes for auth methods (trying to read %" G_GSIZE_FORMAT " now)\n",
-			priv->rxqueue[1], priv->rxqueue[1] - (priv->rxlen - 2));
-		len = read(source, buffer, priv->rxqueue[1] - (priv->rxlen - 2));
+			"reading %d bytes for auth methods (trying to read %hu now)\n",
+			priv->rxqueue[1], to_read);
+		len = read(source, buffer, to_read);
 
 		if(len < 0 && errno == EAGAIN)
 			return;


More information about the Commits mailing list