merged fix from RC_0_16

This commit is contained in:
Arvid Norberg 2013-03-23 03:01:13 +00:00
parent 01f60fa20c
commit a220b8df0c
1 changed files with 16 additions and 0 deletions

View File

@ -2077,6 +2077,22 @@ namespace libtorrent
boost::shared_ptr<torrent> t = associated_torrent().lock();
TORRENT_ASSERT(t);
// piece_block can't necessarily hold large piece numbers
// so check that first
if (r.piece < 0
|| r.piece >= t->torrent_file().num_pieces()
|| r.start < 0
|| r.start > t->torrent_file().piece_length())
{
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING
peer_log("*** INVALID_PIECE [ piece: %d s: %d l: %d ]"
, r.piece, r.start, r.length);
#endif
disconnect(errors::invalid_piece, 2);
return;
}
piece_block b(r.piece, r.start / t->block_size());
m_receiving_block = b;