1
0
mirror of https://github.com/PurpleI2P/i2pd.git synced 2025-01-22 12:24:19 +00:00

correct max paddign size

This commit is contained in:
orignal 2022-09-09 07:23:46 -04:00
parent 23e18a34d4
commit 09e6e2940f

View File

@ -2366,10 +2366,10 @@ namespace transport
size_t SSU2Session::CreatePaddingBlock (uint8_t * buf, size_t len, size_t minSize) size_t SSU2Session::CreatePaddingBlock (uint8_t * buf, size_t len, size_t minSize)
{ {
if (len < minSize) return 0; if (len < 3 || len < minSize) return 0;
uint8_t paddingSize = rand () & 0x0F; // 0 - 15 size_t paddingSize = rand () & 0x0F; // 0 - 15
if (paddingSize > len) paddingSize = len; if (paddingSize + 3 > len) paddingSize = len - 3;
else if (paddingSize < minSize) paddingSize = minSize; else if (paddingSize + 3 < minSize) paddingSize = minSize - 3;
if (paddingSize) if (paddingSize)
{ {
buf[0] = eSSU2BlkPadding; buf[0] = eSSU2BlkPadding;