allocate actual RouterInfo's buffer size

This commit is contained in:
orignal 2019-05-23 09:32:07 -04:00
parent f784cfad46
commit 7b9033d678
3 changed files with 40 additions and 19 deletions

View file

@ -698,14 +698,14 @@ namespace data
LogPrint (eLogDebug, "NetDb: store request: RouterInfo");
size_t size = bufbe16toh (buf + offset);
offset += 2;
if (size > 2048 || size > len - offset)
if (size > MAX_RI_BUFFER_SIZE || size > len - offset)
{
LogPrint (eLogError, "NetDb: invalid RouterInfo length ", (int)size);
return;
}
uint8_t uncompressed[2048];
size_t uncompressedSize = m_Inflator.Inflate (buf + offset, size, uncompressed, 2048);
if (uncompressedSize && uncompressedSize < 2048)
uint8_t uncompressed[MAX_RI_BUFFER_SIZE];
size_t uncompressedSize = m_Inflator.Inflate (buf + offset, size, uncompressed, MAX_RI_BUFFER_SIZE);
if (uncompressedSize && uncompressedSize < MAX_RI_BUFFER_SIZE)
updated = AddRouterInfo (ident, uncompressed, uncompressedSize);
else
{