Browse Source

check out of sequence messages range

pull/1776/head
orignal 2 years ago
parent
commit
c50e453af6
  1. 17
      libi2pd/SSU2Session.cpp

17
libi2pd/SSU2Session.cpp

@ -1174,7 +1174,7 @@ namespace transport @@ -1174,7 +1174,7 @@ namespace transport
m_IsDataReceived = true;
break;
case eSSU2BlkTermination:
LogPrint (eLogDebug, "SSU2: Termination");
LogPrint (eLogDebug, "SSU2: Termination reason=", (int)buf[11]);
Terminate ();
break;
case eSSU2BlkRelayRequest:
@ -2210,12 +2210,10 @@ namespace transport @@ -2210,12 +2210,10 @@ namespace transport
else
++it;
}
if (m_OutOfSequencePackets.size () > 255)
if (!m_OutOfSequencePackets.empty ())
{
m_ReceivePacketNum = *m_OutOfSequencePackets.rbegin ();
m_OutOfSequencePackets.clear ();
}
else if (m_OutOfSequencePackets.size () > SSU2_MAX_NUM_ACK_RANGES)
if (m_OutOfSequencePackets.size () > 2*SSU2_MAX_NUM_ACK_RANGES ||
*m_OutOfSequencePackets.rbegin () > m_ReceivePacketNum + 255*8)
{
uint32_t packet = *m_OutOfSequencePackets.begin ();
if (packet > m_ReceivePacketNum + 1)
@ -2228,6 +2226,13 @@ namespace transport @@ -2228,6 +2226,13 @@ namespace transport
else
LogPrint (eLogError, "SSU2: Out of sequence packet ", packet, " is less than last received ", m_ReceivePacketNum);
}
if (m_OutOfSequencePackets.size () > 255*4)
{
// seems we have a serious network issue
m_ReceivePacketNum = *m_OutOfSequencePackets.rbegin ();
m_OutOfSequencePackets.clear ();
}
}
for (auto it = m_RelaySessions.begin (); it != m_RelaySessions.end ();)
{

Loading…
Cancel
Save