[Mono-list] MonoTorrent error + fix

Alan McGovern alan.mcgovern at gmail.com
Sun Jan 21 18:10:50 EST 2007


I was away on holidays, so i only got the bug report now.

I created a file which was over int.MaxValue bytes in length and used that
to test the monotorrent code. I came across a few places where i was getting
int overflows and commited fixes to SVN. Everything should be ok now
(fingers crossed ;) ).

Let me know how you get on.


On 1/16/07, Will Murnane <will.murnane at gmail.com> wrote:
> I'm writing a BitTorrent client using the bitsharp library, and I
> encountered an error with a torrent that has total file size > 4GB.
> The problem occurs on line 124 of PieceMessage.cs:
> long pieceOffset = this.startOffset + this.PieceIndex *
> this.fileManager.PieceLength;
> this.PieceIndex and this.fileManager.PieceLength are both 32-bit ints;
> when they're multiplied an overflow can result, and pass an
> (overflowed) negative value to FileManager.Read.  My suggestion is to
> cast one of them to long before the multiply is performed:
> long pieceOffset = this.startOffset + (long)this.PieceIndex *
> this.fileManager.PieceLength;
> That should fix the problem.  Here's a screenshot of the debugger
> helping me find the problem:
> http://will.incorrige.us/torrent-error.png
> Last, thanks for the cool library!  I was afraid I'd have to write my
> own bittorrent library to get this working, but bitsharp is working
> (mostly :-P) nicely.
> Thanks,
> Will
> _______________________________________________
> Mono-list maillist  -  Mono-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-list/attachments/20070121/7bf70966/attachment.html 

More information about the Mono-list mailing list