From 52d6a201be778a4611e988ef0e85b96ef73371f3 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Fri, 16 Mar 2007 01:24:40 +0000 Subject: [PATCH] merged error message fix from RC_0_12 branch --- include/libtorrent/peer_id.hpp | 7 +++++++ src/session_impl.cpp | 7 +++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/include/libtorrent/peer_id.hpp b/include/libtorrent/peer_id.hpp index d3bf624b7..e5a224bc4 100755 --- a/include/libtorrent/peer_id.hpp +++ b/include/libtorrent/peer_id.hpp @@ -38,6 +38,7 @@ POSSIBILITY OF SUCH DAMAGE. #include #include #include +#include #include "libtorrent/config.hpp" @@ -55,6 +56,12 @@ namespace libtorrent big_number() {} + big_number(std::string const& s) + { + int sl = int(s.size()) < size ? int(s.size()) : size; + std::memcpy(m_number, &s[0], sl); + } + // when initialized with 0 big_number(private_pointer*) { clear(); } diff --git a/src/session_impl.cpp b/src/session_impl.cpp index cd906f8af..4d7cb2775 100755 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -1810,11 +1810,10 @@ namespace libtorrent { namespace detail } // verify info_hash - const std::string &hash = rd["info-hash"].string(); - std::string real_hash((char*)info.info_hash().begin(), (char*)info.info_hash().end()); - if (hash != real_hash) + sha1_hash hash = rd["info-hash"].string(); + if (hash != info.info_hash()) { - error = "mismatching info-hash: " + hash; + error = "mismatching info-hash: " + boost::lexical_cast(hash); return; }