1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-26 01:27:28 +00:00

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

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;
}