mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-02-08 22:13:48 +01:00
Merge pull request #1016 from majestrate/fix-streaming-overflow
fix overflow
This commit is contained in:
commit
40cfbc5d61
1 changed files with 15 additions and 8 deletions
|
@ -244,6 +244,8 @@ namespace stream
|
||||||
{
|
{
|
||||||
uint8_t signature[256];
|
uint8_t signature[256];
|
||||||
auto signatureLen = m_RemoteIdentity->GetSignatureLen ();
|
auto signatureLen = m_RemoteIdentity->GetSignatureLen ();
|
||||||
|
if(signatureLen <= sizeof(signature))
|
||||||
|
{
|
||||||
memcpy (signature, optionData, signatureLen);
|
memcpy (signature, optionData, signatureLen);
|
||||||
memset (const_cast<uint8_t *>(optionData), 0, signatureLen);
|
memset (const_cast<uint8_t *>(optionData), 0, signatureLen);
|
||||||
if (!m_RemoteIdentity->Verify (packet->GetBuffer (), packet->GetLength (), signature))
|
if (!m_RemoteIdentity->Verify (packet->GetBuffer (), packet->GetLength (), signature))
|
||||||
|
@ -255,6 +257,11 @@ namespace stream
|
||||||
memcpy (const_cast<uint8_t *>(optionData), signature, signatureLen);
|
memcpy (const_cast<uint8_t *>(optionData), signature, signatureLen);
|
||||||
optionData += signatureLen;
|
optionData += signatureLen;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LogPrint(eLogError, "Streaming: Signature too big, ", signatureLen, " bytes");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
packet->offset = packet->GetPayload () - packet->buf;
|
packet->offset = packet->GetPayload () - packet->buf;
|
||||||
if (packet->GetLength () > 0)
|
if (packet->GetLength () > 0)
|
||||||
|
|
Loading…
Add table
Reference in a new issue