mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-03-21 16:49:10 +01:00
Merge pull request #1950 from Vort/term_fix
fix termination block processing and size check
This commit is contained in:
commit
5e97b54d1b
2 changed files with 15 additions and 10 deletions
|
@ -884,7 +884,7 @@ namespace transport
|
||||||
auto size = bufbe16toh (frame + offset);
|
auto size = bufbe16toh (frame + offset);
|
||||||
offset += 2;
|
offset += 2;
|
||||||
LogPrint (eLogDebug, "NTCP2: Block type ", (int)blk, " of size ", size);
|
LogPrint (eLogDebug, "NTCP2: Block type ", (int)blk, " of size ", size);
|
||||||
if (size > len)
|
if (offset + size > len)
|
||||||
{
|
{
|
||||||
LogPrint (eLogError, "NTCP2: Unexpected block length ", size);
|
LogPrint (eLogError, "NTCP2: Unexpected block length ", size);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -1486,7 +1486,7 @@ namespace transport
|
||||||
auto size = bufbe16toh (buf + offset);
|
auto size = bufbe16toh (buf + offset);
|
||||||
offset += 2;
|
offset += 2;
|
||||||
LogPrint (eLogDebug, "SSU2: Block type ", (int)blk, " of size ", size);
|
LogPrint (eLogDebug, "SSU2: Block type ", (int)blk, " of size ", size);
|
||||||
if (size > len)
|
if (offset + size > len)
|
||||||
{
|
{
|
||||||
LogPrint (eLogError, "SSU2: Unexpected block length ", size);
|
LogPrint (eLogError, "SSU2: Unexpected block length ", size);
|
||||||
break;
|
break;
|
||||||
|
@ -1532,7 +1532,9 @@ namespace transport
|
||||||
break;
|
break;
|
||||||
case eSSU2BlkTermination:
|
case eSSU2BlkTermination:
|
||||||
{
|
{
|
||||||
uint8_t rsn = buf[11]; // reason
|
if (size >= 9)
|
||||||
|
{
|
||||||
|
uint8_t rsn = buf[offset + 8]; // reason
|
||||||
LogPrint (eLogDebug, "SSU2: Termination reason=", (int)rsn);
|
LogPrint (eLogDebug, "SSU2: Termination reason=", (int)rsn);
|
||||||
if (IsEstablished () && rsn != eSSU2TerminationReasonTerminationReceived)
|
if (IsEstablished () && rsn != eSSU2TerminationReasonTerminationReceived)
|
||||||
RequestTermination (eSSU2TerminationReasonTerminationReceived);
|
RequestTermination (eSSU2TerminationReasonTerminationReceived);
|
||||||
|
@ -1542,6 +1544,9 @@ namespace transport
|
||||||
m_State = eSSU2SessionStateClosingConfirmed;
|
m_State = eSSU2SessionStateClosingConfirmed;
|
||||||
Done ();
|
Done ();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
LogPrint(eLogWarning, "SSU2: Unexpected termination block size ", size);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case eSSU2BlkRelayRequest:
|
case eSSU2BlkRelayRequest:
|
||||||
|
|
Loading…
Add table
Reference in a new issue