Merge pull request #232 from ssiloti/item-assign-assert

assert that the signature is valid when assigning a mutable value to …
This commit is contained in:
Arvid Norberg 2015-10-23 20:19:12 -04:00
commit 9399033588
1 changed files with 11 additions and 0 deletions

View File

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