mirror of
https://github.com/PurpleI2P/i2pd
synced 2024-11-10 00:00:29 +03:00
set actual LeaseSet2 buffer size
This commit is contained in:
parent
168da33d8b
commit
962c2160c7
@ -251,6 +251,13 @@ namespace data
|
||||
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):
|
||||
LeaseSet (storeLeases), m_StoreType (storeType), m_EncryptionType (preferredCrypto)
|
||||
{
|
||||
@ -331,6 +338,8 @@ namespace data
|
||||
VerifySignature (identity, buf, len, offset);
|
||||
SetIsValid (verified);
|
||||
}
|
||||
offset += m_TransientVerifier ? m_TransientVerifier->GetSignatureLen () : identity->GetSignatureLen ();
|
||||
SetBufferLen (offset);
|
||||
}
|
||||
|
||||
template<typename Verifier>
|
||||
@ -537,6 +546,12 @@ namespace data
|
||||
else
|
||||
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
|
||||
|
@ -97,6 +97,7 @@ namespace data
|
||||
// called from LeaseSet2
|
||||
LeaseSet (bool storeLeases);
|
||||
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 SetExpirationTime (uint64_t t) { m_ExpirationTime = t; };
|
||||
void SetIsValid (bool isValid) { m_IsValid = isValid; };
|
||||
|
Loading…
Reference in New Issue
Block a user