From c0b6e5769e6d8e822db12ed8ba2e6c3740c0834a Mon Sep 17 00:00:00 2001 From: Evgeny Date: Thu, 4 Jun 2026 00:57:19 +0300 Subject: [PATCH] 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) --- src/etcp_connections.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/etcp_connections.c b/src/etcp_connections.c index 59b65c30..f9b64f20 100644 --- a/src/etcp_connections.c +++ b/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;