mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 08:14:15 +00:00
some cleanup
This commit is contained in:
parent
e90baf3ca6
commit
6f0a136727
10
Identity.cpp
10
Identity.cpp
@ -234,10 +234,7 @@ namespace data
|
|||||||
size_t IdentityEx::ToBuffer (uint8_t * buf, size_t len) const
|
size_t IdentityEx::ToBuffer (uint8_t * buf, size_t len) const
|
||||||
{
|
{
|
||||||
const size_t fullLen = GetFullLen();
|
const size_t fullLen = GetFullLen();
|
||||||
if (fullLen > len) {
|
if (fullLen > len) return 0; // buffer is too small and may overflow somewhere else
|
||||||
// buffer is too small and may overflow somewhere else
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
memcpy (buf, &m_StandardIdentity, DEFAULT_IDENTITY_SIZE);
|
memcpy (buf, &m_StandardIdentity, DEFAULT_IDENTITY_SIZE);
|
||||||
if (m_ExtendedLen > 0 && m_ExtendedBuffer)
|
if (m_ExtendedLen > 0 && m_ExtendedBuffer)
|
||||||
memcpy (buf + DEFAULT_IDENTITY_SIZE, m_ExtendedBuffer, m_ExtendedLen);
|
memcpy (buf + DEFAULT_IDENTITY_SIZE, m_ExtendedBuffer, m_ExtendedLen);
|
||||||
@ -247,9 +244,8 @@ namespace data
|
|||||||
size_t IdentityEx::FromBase64(const std::string& s)
|
size_t IdentityEx::FromBase64(const std::string& s)
|
||||||
{
|
{
|
||||||
const size_t slen = s.length();
|
const size_t slen = s.length();
|
||||||
const size_t bufLen = Base64EncodingBufferSize(slen);
|
uint8_t buf[slen]; // binary data can't exceed base64
|
||||||
uint8_t buf[bufLen];
|
const size_t len = Base64ToByteStream (s.c_str(), slen, buf, slen);
|
||||||
const size_t len = Base64ToByteStream (s.c_str(), slen, buf, bufLen);
|
|
||||||
return FromBuffer (buf, len);
|
return FromBuffer (buf, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user