eith0s / rutorrent

Automatically exported from code.google.com/p/rutorrent
0 stars 0 forks source link

Extra piece generated when file length is multiple of piece size #811

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Create a new torrent using rutorrent/php/Torrent.php for a single file of 
which the length is an exact multiple of the selected piece size.

What is the expected output? What do you see instead?
I expect all hash pieces to be hashes of some part of the data, instead there 
is one extra piece which is the hash of nothing 
(da39a3ee5e6b4b0d3255bfef95601890afd80709). In my testing, such a torrent file 
was rejected by Transmission, qTorrent, Deluge, uTorrent, and BitTornado. It 
appears to work, however, in rtorrent and Vuze.

What environment are you using?
Someone else generated the torrent file, and I don't know the details of their 
environment.

Are some errors present in the web-server log?
Probably not.

Are some errors present in the browser error console?
Probably not.

Please provide any additional information below.
feof() only returns true after you have tried to read past the EOF (see 
http://www.php.net/manual/en/function.feof.php#67261 ). One solution should be 
to change lines 438-439 in 
https://code.google.com/p/rutorrent/source/browse/trunk/rutorrent/php/Torrent.ph
p?r=2115 to something like (not tested):

                while( $piece = fread( $handle, $piece_length ) )
                        $pieces .= self::pack( $piece ) );

The multiple file case looks like it works correctly already.

Original issue reported on code.google.com by ringoka...@yahoo.com on 15 Mar 2013 at 8:11

GoogleCodeExporter commented 8 years ago

Original comment by novik65 on 18 Mar 2013 at 3:37

GoogleCodeExporter commented 8 years ago

Original comment by novik65 on 19 Mar 2013 at 10:09