diff --git a/libi2pd/SSUData.cpp b/libi2pd/SSUData.cpp index d789e70e..3ad5e769 100644 --- a/libi2pd/SSUData.cpp +++ b/libi2pd/SSUData.cpp @@ -320,7 +320,7 @@ namespace transport uint8_t * msgBuf = msg->GetSSUHeader (); uint32_t fragmentNum = 0; - while (len > 0) + while (len > 0 && fragmentNum <= 127) { Fragment * fragment = new Fragment; fragment->fragmentNum = fragmentNum; @@ -332,7 +332,7 @@ namespace transport payload++; htobe32buf (payload, msgID); payload += 4; - bool isLast = (len <= payloadSize); + bool isLast = (len <= payloadSize) || fragmentNum == 127; // 127 fragments max size_t size = isLast ? len : payloadSize; uint32_t fragmentInfo = (fragmentNum << 17); if (isLast) diff --git a/libi2pd/SSUSession.cpp b/libi2pd/SSUSession.cpp index 2a8cd2d5..255adf42 100644 --- a/libi2pd/SSUSession.cpp +++ b/libi2pd/SSUSession.cpp @@ -929,7 +929,13 @@ namespace transport if (m_State == eSessionStateEstablished) { for (const auto& it: msgs) - if (it) m_Data.Send (it); + if (it) + { + if (it->GetLength () <= SSU_MAX_I2NP_MESSAGE_SIZE) + m_Data.Send (it); + else + LogPrint (eLogError, "SSU: I2NP message of size ", it->GetLength (), " can't be sent. Dropped"); + } } } diff --git a/libi2pd/SSUSession.h b/libi2pd/SSUSession.h index 8247c420..7f053d37 100644 --- a/libi2pd/SSUSession.h +++ b/libi2pd/SSUSession.h @@ -28,6 +28,7 @@ namespace transport const int SSU_CONNECT_TIMEOUT = 5; // 5 seconds const int SSU_TERMINATION_TIMEOUT = 330; // 5.5 minutes const int SSU_CLOCK_SKEW = 60; // in seconds + const size_t SSU_MAX_I2NP_MESSAGE_SIZE = 32768; // payload types (4 bits) const uint8_t PAYLOAD_TYPE_SESSION_REQUEST = 0;