mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2024-11-04 06:00:37 +00:00
fixed #1644. check leaseset buffer size
This commit is contained in:
parent
ac10f3055d
commit
34eee2fc26
@ -72,6 +72,12 @@ namespace data
|
|||||||
}
|
}
|
||||||
size += 256; // encryption key
|
size += 256; // encryption key
|
||||||
size += m_Identity->GetSigningPublicKeyLen (); // unused signing key
|
size += m_Identity->GetSigningPublicKeyLen (); // unused signing key
|
||||||
|
if (size + 1 > m_BufferLen)
|
||||||
|
{
|
||||||
|
LogPrint (eLogError, "LeaseSet: ", size, " exceeds buffer size ", m_BufferLen);
|
||||||
|
m_IsValid = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
uint8_t num = m_Buffer[size];
|
uint8_t num = m_Buffer[size];
|
||||||
size++; // num
|
size++; // num
|
||||||
LogPrint (eLogDebug, "LeaseSet: read num=", (int)num);
|
LogPrint (eLogDebug, "LeaseSet: read num=", (int)num);
|
||||||
@ -81,9 +87,14 @@ namespace data
|
|||||||
m_IsValid = false;
|
m_IsValid = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (size + num*LEASE_SIZE > m_BufferLen)
|
||||||
|
{
|
||||||
|
LogPrint (eLogError, "LeaseSet: ", size, " exceeds buffer size ", m_BufferLen);
|
||||||
|
m_IsValid = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
UpdateLeasesBegin ();
|
UpdateLeasesBegin ();
|
||||||
|
|
||||||
// process leases
|
// process leases
|
||||||
m_ExpirationTime = 0;
|
m_ExpirationTime = 0;
|
||||||
auto ts = i2p::util::GetMillisecondsSinceEpoch ();
|
auto ts = i2p::util::GetMillisecondsSinceEpoch ();
|
||||||
@ -106,14 +117,22 @@ namespace data
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_ExpirationTime += LEASE_ENDDATE_THRESHOLD;
|
m_ExpirationTime += LEASE_ENDDATE_THRESHOLD;
|
||||||
|
|
||||||
UpdateLeasesEnd ();
|
UpdateLeasesEnd ();
|
||||||
|
|
||||||
// verify
|
// verify
|
||||||
if (verifySignature && !m_Identity->Verify (m_Buffer, leases - m_Buffer, leases))
|
if (verifySignature)
|
||||||
{
|
{
|
||||||
LogPrint (eLogWarning, "LeaseSet: verification failed");
|
auto signedSize = leases - m_Buffer;
|
||||||
m_IsValid = false;
|
if (signedSize + m_Identity->GetSignatureLen () > m_BufferLen)
|
||||||
|
{
|
||||||
|
LogPrint (eLogError, "LeaseSet: Signature exceeds buffer size ", m_BufferLen);
|
||||||
|
m_IsValid = false;
|
||||||
|
}
|
||||||
|
else if (!m_Identity->Verify (m_Buffer, signedSize, leases))
|
||||||
|
{
|
||||||
|
LogPrint (eLogWarning, "LeaseSet: verification failed");
|
||||||
|
m_IsValid = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user