Heya,

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.

Alan.

On 1/16/07, Will Murnane <[EMAIL PROTECTED]> 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  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-list

_______________________________________________
Mono-list maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-list

Reply via email to