torrent my_peer_id fix for large PIDs

Solar Designer <[email protected]> Thu, 12 Apr 2012 23:14:01 +0400
Newsgroups gmane.linux.openwall.devel,gmane.network.lftp.devel
Message-ID <[email protected]>
--sdtB3X0nJg68CQEu
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

Alexander,

Attached is a patch against lftp 4.3.6 to fix
my_peer_id.length()==PEER_ID_LEN assertion failure when lftp's PID is
above 0xffff.  I think you may apply this as-is or you may choose to
unambiguously encode larger PIDs in my_peer_id somehow.

Thanks,

Alexander

--sdtB3X0nJg68CQEu
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="lftp-4.3.6-owl-torrent-my_peer_id.diff"

--- lftp-4.3.6/src/Torrent.cc.orig	2012-02-14 10:09:24 +0000
+++ lftp-4.3.6/src/Torrent.cc	2012-04-12 18:56:46 +0000
@@ -173,7 +173,7 @@ Torrent::Torrent(const char *mf,const ch
    }
    if(!my_peer_id) {
       my_peer_id.set("-lftp43-");
-      my_peer_id.appendf("%04x",(unsigned)getpid());
+      my_peer_id.appendf("%04x",(unsigned)getpid() & 0xffff);
       my_peer_id.appendf("%08x",(unsigned)now.UnixTime());
       assert(my_peer_id.length()==PEER_ID_LEN);
    }

--sdtB3X0nJg68CQEu--