From 4151c8e36653e08e5e7b3fc4530142f457383e1b Mon Sep 17 00:00:00 2001 From: Steven Siloti Date: Wed, 21 Oct 2015 20:26:41 -0700 Subject: [PATCH] assert that the signature is valid when assigning a mutable value to an item --- src/kademlia/item.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/kademlia/item.cpp b/src/kademlia/item.cpp index 6f10cc30b..6a56ca034 100644 --- a/src/kademlia/item.cpp +++ b/src/kademlia/item.cpp @@ -213,6 +213,17 @@ bool item::assign(bdecode_node const& v void item::assign(entry const& v, std::string salt, boost::uint64_t seq , char const* pk, char const* sig) { +#if TORRENT_USE_ASSERTS + TORRENT_ASSERT(pk && sig); + char buffer[1000]; + int bsize = bencode(buffer, v); + TORRENT_ASSERT(bsize <= 1000); + TORRENT_ASSERT(verify_mutable_item( + std::make_pair(buffer, bsize) + , std::make_pair(salt.data(), int(salt.size())) + , seq, pk, sig)); +#endif + memcpy(m_pk.c_array(), pk, item_pk_len); memcpy(m_sig.c_array(), sig, item_sig_len); m_salt = salt;