diff --git a/src/file_storage.cpp b/src/file_storage.cpp index 46aaa3aec..3942bd1d3 100644 --- a/src/file_storage.cpp +++ b/src/file_storage.cpp @@ -58,8 +58,8 @@ namespace libtorrent if (index == num_pieces()-1) { size_type size_except_last = num_pieces() - 1; - size_except_last *= piece_length(); - int size = int(total_size() - size_except_last); + size_except_last *= size_type(piece_length()); + size_type size = total_size() - size_except_last; TORRENT_ASSERT(size > 0); TORRENT_ASSERT(size <= piece_length()); return int(size); diff --git a/src/torrent.cpp b/src/torrent.cpp index c9fc7e21c..75001a248 100644 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -1289,7 +1289,7 @@ namespace libtorrent #ifdef TORRENT_USE_OPENSSL -#if BOOST_VERSION > 104700 +#if BOOST_VERSION >= 104700 bool torrent::verify_peer_cert(bool preverified, boost::asio::ssl::verify_context& ctx) { // if the cert wasn't signed by the correct CA, fail the verification diff --git a/src/utp_stream.cpp b/src/utp_stream.cpp index a249d9421..6f4759641 100644 --- a/src/utp_stream.cpp +++ b/src/utp_stream.cpp @@ -2839,6 +2839,9 @@ int utp_socket_impl::packet_timeout() const // have an RTT estimate yet, make a conservative guess if (m_state == UTP_STATE_NONE) return 3000; + // avoid overflow by simply capping based on number of timeouts as well + if (m_num_timeouts >= 7) return 60000; + int timeout = (std::max)(m_sm->min_timeout(), m_rtt.mean() + m_rtt.avg_deviation() * 2); if (m_num_timeouts > 0) timeout += (1 << (int(m_num_timeouts) - 1)) * 1000; return timeout;