fixed assert in ut_metadata plugin

This commit is contained in:
Arvid Norberg 2009-11-01 19:07:20 +00:00
parent deb363e53b
commit 2897389409
2 changed files with 13 additions and 1 deletions

View File

@ -97,6 +97,7 @@ release 0.14.7
* fixed bug in error handling when parsing torrent files
* fixed file checking bug when renaming a file before checking the torrent
* fixed race conditon when receiving metadata from swarm
* fixed assert in ut_metadata plugin
release 0.14.6

View File

@ -119,7 +119,18 @@ namespace libtorrent { namespace
if (piece < 0 || piece >= int(m_requested_metadata.size()))
return false;
TORRENT_ASSERT(piece * 16 * 1024 + size <= m_metadata_size);
if (total_size != m_metadata_size)
{
// they disagree about the size!
return false;
}
if (piece * 16 * 1024 + size > m_metadata_size)
{
// this piece is invalid
return false;
}
std::memcpy(&m_metadata[piece * 16 * 1024], buf, size);
// mark this piece has 'have'
m_requested_metadata[piece] = (std::numeric_limits<int>::max)();