Browse Source

check message length

pull/1499/head
orignal 5 years ago
parent
commit
744e893dce
  1. 8
      libi2pd_client/I2CP.cpp
  2. 1
      libi2pd_client/I2CP.h

8
libi2pd_client/I2CP.cpp

@ -245,10 +245,18 @@ namespace client @@ -245,10 +245,18 @@ namespace client
{
m_PayloadLen = bufbe32toh (m_Header + I2CP_HEADER_LENGTH_OFFSET);
if (m_PayloadLen > 0)
{
if (m_PayloadLen <= I2CP_MAX_MESSAGE_LENGTH)
{
m_Payload = new uint8_t[m_PayloadLen];
ReceivePayload ();
}
else
{
LogPrint (eLogError, "I2CP: Unexpected payload length ", m_PayloadLen);
Terminate ();
}
}
else // no following payload
{
HandleMessage ();

1
libi2pd_client/I2CP.h

@ -24,6 +24,7 @@ namespace client @@ -24,6 +24,7 @@ namespace client
{
const uint8_t I2CP_PROTOCOL_BYTE = 0x2A;
const size_t I2CP_SESSION_BUFFER_SIZE = 4096;
const size_t I2CP_MAX_MESSAGE_LENGTH = 65535;
const size_t I2CP_HEADER_LENGTH_OFFSET = 0;
const size_t I2CP_HEADER_TYPE_OFFSET = I2CP_HEADER_LENGTH_OFFSET + 4;

Loading…
Cancel
Save