Browse Source

set actual LeaseSet2 buffer size

pull/1499/head
orignal 5 years ago
parent
commit
962c2160c7
  1. 15
      libi2pd/LeaseSet.cpp
  2. 1
      libi2pd/LeaseSet.h

15
libi2pd/LeaseSet.cpp

@ -251,6 +251,13 @@ namespace data
memcpy (m_Buffer, buf, len); memcpy (m_Buffer, buf, len);
} }
void LeaseSet::SetBufferLen (size_t len)
{
if (len <= m_BufferLen) m_BufferLen = len;
else
LogPrint (eLogError, "LeaseSet2: actual buffer size ", len , " exceeds full buffer size ", m_BufferLen);
}
LeaseSet2::LeaseSet2 (uint8_t storeType, const uint8_t * buf, size_t len, bool storeLeases, CryptoKeyType preferredCrypto): LeaseSet2::LeaseSet2 (uint8_t storeType, const uint8_t * buf, size_t len, bool storeLeases, CryptoKeyType preferredCrypto):
LeaseSet (storeLeases), m_StoreType (storeType), m_EncryptionType (preferredCrypto) LeaseSet (storeLeases), m_StoreType (storeType), m_EncryptionType (preferredCrypto)
{ {
@ -331,6 +338,8 @@ namespace data
VerifySignature (identity, buf, len, offset); VerifySignature (identity, buf, len, offset);
SetIsValid (verified); SetIsValid (verified);
} }
offset += m_TransientVerifier ? m_TransientVerifier->GetSignatureLen () : identity->GetSignatureLen ();
SetBufferLen (offset);
} }
template<typename Verifier> template<typename Verifier>
@ -537,6 +546,12 @@ namespace data
else else
LogPrint (eLogError, "LeaseSet2: unexpected LeaseSet type ", (int)innerPlainText[0], " inside encrypted LeaseSet"); LogPrint (eLogError, "LeaseSet2: unexpected LeaseSet type ", (int)innerPlainText[0], " inside encrypted LeaseSet");
} }
else
{
// we set actual length of encrypted buffer
offset += m_TransientVerifier ? m_TransientVerifier->GetSignatureLen () : blindedVerifier->GetSignatureLen ();
SetBufferLen (offset);
}
} }
// helper for ExtractClientAuthData // helper for ExtractClientAuthData

1
libi2pd/LeaseSet.h

@ -97,6 +97,7 @@ namespace data
// called from LeaseSet2 // called from LeaseSet2
LeaseSet (bool storeLeases); LeaseSet (bool storeLeases);
void SetBuffer (const uint8_t * buf, size_t len); void SetBuffer (const uint8_t * buf, size_t len);
void SetBufferLen (size_t len);
void SetIdentity (std::shared_ptr<const IdentityEx> identity) { m_Identity = identity; }; void SetIdentity (std::shared_ptr<const IdentityEx> identity) { m_Identity = identity; };
void SetExpirationTime (uint64_t t) { m_ExpirationTime = t; }; void SetExpirationTime (uint64_t t) { m_ExpirationTime = t; };
void SetIsValid (bool isValid) { m_IsValid = isValid; }; void SetIsValid (bool isValid) { m_IsValid = isValid; };

Loading…
Cancel
Save