check garlic clove length

This commit is contained in:
orignal 2015-04-21 18:59:35 -04:00
parent 7ec701a816
commit 969695f318

View File

@ -461,6 +461,7 @@ namespace garlic
void GarlicDestination::HandleGarlicPayload (uint8_t * buf, size_t len, std::shared_ptr<i2p::tunnel::InboundTunnel> from) void GarlicDestination::HandleGarlicPayload (uint8_t * buf, size_t len, std::shared_ptr<i2p::tunnel::InboundTunnel> from)
{ {
const uint8_t * buf1 = buf;
int numCloves = buf[0]; int numCloves = buf[0];
LogPrint (numCloves," cloves"); LogPrint (numCloves," cloves");
buf++; buf++;
@ -518,6 +519,11 @@ namespace garlic
buf += 4; // CloveID buf += 4; // CloveID
buf += 8; // Date buf += 8; // Date
buf += 3; // Certificate buf += 3; // Certificate
if (buf - buf1 > (int)len)
{
LogPrint (eLogError, "Gralic clove is too long");
break;
}
} }
} }