Merge remote-tracking branch 'purple/openssl'

Conflicts:
	I2CP.cpp
This commit is contained in:
Jeff Becker 2016-06-08 10:37:51 -04:00
commit a1c81a63dd
No known key found for this signature in database
GPG Key ID: AB950234D6EA286B

View File

@ -164,26 +164,34 @@ namespace client
Terminate (); Terminate ();
else else
{ {
size_t offset = 0; size_t offset = 0; // from m_Buffer
if (m_NextMessage) if (m_NextMessage)
{ {
if (m_NextMessageOffset + bytes_transferred <= m_NextMessageLen) if (m_NextMessageOffset + bytes_transferred <= m_NextMessageLen)
{ {
memcpy (m_NextMessage + m_NextMessageOffset, m_Buffer, bytes_transferred); memcpy (m_NextMessage + m_NextMessageOffset, m_Buffer, bytes_transferred);
m_NextMessageOffset += bytes_transferred; m_NextMessageOffset += bytes_transferred;
offset = bytes_transferred;
} }
else else
{ {
// m_NextMessage complete
offset = m_NextMessageLen - m_NextMessageOffset; offset = m_NextMessageLen - m_NextMessageOffset;
memcpy (m_NextMessage + m_NextMessageOffset, m_Buffer, offset); memcpy (m_NextMessage + m_NextMessageOffset, m_Buffer, offset);
HandleNextMessage (m_NextMessage); HandleNextMessage (m_NextMessage);
delete[] m_NextMessage; delete[] m_NextMessage;
m_NextMessage = nullptr m_NextMessage = nullptr;
} }
} }
while (offset < bytes_transferred) while (offset < bytes_transferred)
{ {
auto msgLen = bufbe32toh (m_Buffer + offset + I2CP_HEADER_LENGTH_OFFSET) + I2CP_HEADER_SIZE; auto msgLen = bufbe32toh (m_Buffer + offset + I2CP_HEADER_LENGTH_OFFSET) + I2CP_HEADER_SIZE;
if (msgLen > 0xFFFF) // 64K
{
LogPrint (eLogError, "I2CP: message length ", msgLen, " exceeds 64K. Terminated");
Terminate ();
return;
}
if (msgLen <= bytes_transferred - offset) if (msgLen <= bytes_transferred - offset)
{ {
HandleNextMessage (m_Buffer + offset); HandleNextMessage (m_Buffer + offset);
@ -218,6 +226,11 @@ namespace client
m_Destination->Stop (); m_Destination->Stop ();
m_Destination = nullptr; m_Destination = nullptr;
} }
if (m_Socket)
{
m_Socket->close ();
m_Socket = nullptr;
}
m_Owner.RemoveSession (GetSessionID ()); m_Owner.RemoveSession (GetSessionID ());
} }