Browse Source

fix: correct INIT padding cap using defines instead of hardcoded 19

Formula: s_max = mtu - 3 - SC_TAG_SIZE + UDP_SC_HDR_SIZE - SC_PUBKEY_ENC_SIZE
For mtu=1460: 1460 - 3 - 16 + 30 - 72 = 1399 (was 1390, off by 9)
etcp-inflight-fix
Evgeny 4 months ago
parent
commit
c0b6e5769e
  1. 2
      src/etcp_connections.c

2
src/etcp_connections.c

@ -133,7 +133,7 @@ static void etcp_link_send_init(struct ETCP_LINK* link, uint8_t reset) {
// padding
int s = rand() % (link->handshake_maxsize - link->handshake_minsize) + link->handshake_minsize;
int s_max = (int)(link->mtu - UDP_HDR_SIZE) - (int)offset - 19; // 19=3hdr+16tag-72unenc
int s_max = (int)(link->mtu) - 3 - (int)SC_TAG_SIZE + (int)UDP_SC_HDR_SIZE - (int)SC_PUBKEY_ENC_SIZE;
if (s > s_max) s = s_max;
if (s < 0) s = 0;

Loading…
Cancel
Save