Browse Source

fix overflow

pull/1016/head
Jeff Becker 7 years ago
parent
commit
e1b5803902
No known key found for this signature in database
GPG Key ID: F357B3B42F6F9B05
  1. 9
      libi2pd/Streaming.cpp

9
libi2pd/Streaming.cpp

@ -242,8 +242,10 @@ namespace stream
if (flags & PACKET_FLAG_SIGNATURE_INCLUDED) if (flags & PACKET_FLAG_SIGNATURE_INCLUDED)
{ {
uint8_t signature[256]; uint8_t signature[512];
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…
Cancel
Save