fix handshake.c crash reported by wereHamster

This commit is contained in:
Charles Kerr 2008-06-05 16:25:22 +00:00
parent ab17f553c4
commit d3d4047da0
1 changed files with 3 additions and 2 deletions

View File

@ -228,9 +228,10 @@ parseHandshake( tr_handshake * handshake,
/* torrent hash */
tr_peerIoReadBytes( handshake->io, inbuf, hash, sizeof(hash) );
assert( tr_torrentExists( handshake->handle, hash ) );
assert( tr_peerIoHasTorrentHash( handshake->io ) );
if( memcmp( hash, tr_peerIoGetTorrentHash(handshake->io), SHA_DIGEST_LENGTH ) ) {
if( !tr_torrentExists( handshake->handle, hash )
|| memcmp( hash, tr_peerIoGetTorrentHash(handshake->io), SHA_DIGEST_LENGTH ) )
{
dbgmsg( handshake, "peer returned the wrong hash. wtf?" );
return HANDSHAKE_BAD_TORRENT;
}