check TokenRequest message size

This commit is contained in:
orignal 2022-06-27 15:56:47 -04:00
parent a99fcfe54f
commit 72b61a29c2

View File

@ -788,6 +788,11 @@ namespace transport
void SSU2Session::ProcessTokenRequest (Header& header, uint8_t * buf, size_t len) void SSU2Session::ProcessTokenRequest (Header& header, uint8_t * buf, size_t len)
{ {
// we are Bob // we are Bob
if (len < 48)
{
LogPrint (eLogWarning, "SSU2: Incorrect TokenRequest len ", len);
return;
}
uint8_t nonce[12] = {0}; uint8_t nonce[12] = {0};
uint8_t h[32]; uint8_t h[32];
memcpy (h, header.buf, 16); memcpy (h, header.buf, 16);
@ -920,6 +925,7 @@ namespace transport
bool SSU2Session::ProcessHolePunch (uint8_t * buf, size_t len) bool SSU2Session::ProcessHolePunch (uint8_t * buf, size_t len)
{ {
// we are Alice // we are Alice
LogPrint (eLogDebug, "HolePunch");
Header header; Header header;
memcpy (header.buf, buf, 16); memcpy (header.buf, buf, 16);
header.ll[0] ^= CreateHeaderMask (i2p::context.GetSSU2IntroKey (), buf + (len - 24)); header.ll[0] ^= CreateHeaderMask (i2p::context.GetSSU2IntroKey (), buf + (len - 24));