On 28/05/2007, at 9:36 PM, Alexander Tsvyashchenko wrote: > > Hello All, > > It looks like pymsn-t 0.11.2 contains the code that breaks avatars > support on x86_64 systems. > > More specifically, when generating session IDs, it uses calls like > random.randint(1000, sys.maxint) - but the issue is that sys.maxint > returns 64 bit integers, while MSN protocol, as far as I understood, > uses 32 bit ones - thus, slicing occurs and session ID in packets does > not match stored session ID - so packets are silently discarded. > > I've spent more than 4 hours to debug that, but I hope it was not in > vain and can help smb besides me ;-) > > My (quick-and-dirty) patch is below, it solved the problem on my PC. > > I was not really sure what maxint places were safe and what were not, > so I've replaced all of them to be sure. The place where it is > certainly required is msn.py: 2713 > > ====================================================================== > ==== > diff -urN pymsnt-0.11.2/src/ft.py pymsnt-0.11.2.patched/src/ft.py > --- pymsnt-0.11.2/src/ft.py 2006-10-18 07:40:55.000000000 +0300 > +++ pymsnt-0.11.2.patched/src/ft.py 2007-05-28 13:17:18.000000000 > +0300 > @@ -14,6 +14,8 @@ > import random > import sys > > +SYS_MAXINT = 2147483647 > + > > def doRateLimit(setConsumer, consumer): > try: > @@ -208,7 +210,7 @@ > del self.legacyftp > > LogEvent(INFO, self.ident) > - self.sid = str(random.randint(1000, sys.maxint)) > + self.sid = str(random.randint(1000, SYS_MAXINT)) > iq = Element((None, "iq")) > iq.attributes["type"] = "set" > iq.attributes["to"] = self.toJID > diff -urN pymsnt-0.11.2/src/legacy/msn/msn.py > pymsnt-0.11.2.patched/src/legacy/msn/msn.py > --- pymsnt-0.11.2/src/legacy/msn/msn.py 2006-10-18 > 07:40:54.000000000 +0300 > +++ pymsnt-0.11.2.patched/src/legacy/msn/msn.py 2007-05-28 > 13:16:40.000000000 +0300 > @@ -150,6 +150,8 @@ > MESSAGEDEBUG = False > MSNP2PDEBUG = False > > +SYS_MAXINT = 2147483647 > + > > P2PSEQ = [-3, -2, 0, -1, 1, 2, 3, 4, 5, 6, 7, 8] > def p2pseq(n): > @@ -2686,7 +2688,7 @@ > if baseID: > self.baseID = baseID > else: > - self.baseID = random.randint(1000, sys.maxint) > + self.baseID = random.randint(1000, SYS_MAXINT) > self.pos = -1 > > def get(self): > @@ -2713,7 +2715,7 @@ > def __init__(self, remoteUser, switchboard, sessionID, > sessionGuid): > self.dataFlag = 0 > if not sessionID: > - sessionID = random.randint(1000, sys.maxint) > + sessionID = random.randint(1000, SYS_MAXINT) > if not sessionGuid: > sessionGuid = random_guid() > self.remoteUser = remoteUser > @@ -2759,7 +2761,7 @@ > binaryFields[1] = self.seqID.next() > binaryFields[3] = len(msgStr) > binaryFields[4] = binaryFields[3] > - binaryFields[6] = random.randint(1000, sys.maxint) > + binaryFields[6] = random.randint(1000, SYS_MAXINT) > self.sendP2PMessage(binaryFields, msgStr) > > def sendP2PMessage(self, binaryFields, msgStr): > @@ -2793,7 +2795,7 @@ > binaryFields[1] = self.seqID.next() > binaryFields[3] = 4 > binaryFields[4] = 4 > - binaryFields[6] = random.randint(1000, sys.maxint) > + binaryFields[6] = random.randint(1000, SYS_MAXINT) > binaryFields[9] = 1 > self.sendP2PMessage(binaryFields, chr(0) * 4) > > @@ -2823,7 +2825,7 @@ > binaryFields[3] = self.filesize > binaryFields[4] = len(chunk) > binaryFields[5] = self.dataFlag > - binaryFields[6] = random.randint(1000, sys.maxint) > + binaryFields[6] = random.randint(1000, SYS_MAXINT) > binaryFields[9] = 1 > self.offset += len(chunk) > self.sendP2PMessage(binaryFields, chunk) > ====================================================================== > ==== > > Good luck! Alexander
Thanks. --- James _______________________________________________ py-transports mailing list py-transports@blathersource.org http://lists.modevia.com/cgi-bin/mailman/listinfo/py-transports