@ -134,7 +134,8 @@ 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 ) - 3 - ( int ) SC_TAG_SIZE + ( int ) UDP_SC_HDR_SIZE - ( int ) SC_PUBKEY_ENC_SIZE ;
if ( s > s_max ) s = s_max ;
DEBUG_ERROR ( DEBUG_CATEGORY_CONNECTION , " INIT_REQ: mtu=%d s=%d s_max=%d offset=%zu " , ( int ) link - > mtu , s , s_max , offset ) ;
if ( s > s_max ) { DEBUG_ERROR ( DEBUG_CATEGORY_CONNECTION , " INIT_REQ capped s=%d -> %d " , s , s_max ) ; s = s_max ; }
if ( s < 0 ) s = 0 ;
int to_add = s - offset - UDP_HDR_SIZE - UDP_SC_HDR_SIZE ;
@ -1531,9 +1532,12 @@ void etcp_connections_read_callback_socket(socket_t sock, void* arg) {
int xoffset = sizeof ( * ack_repl_hdr ) ;
// padding
int s = rand ( ) % ( link - > handshake_maxsize - link - > handshake_minsize ) + link - > handshake_minsize ;
if ( s > link - > mtu ) s = link - > mtu ;
// Cap s: final encrypted = s - 26 for RESPONSE (noencrypt=0)
if ( s > 1472 + 26 ) s = 1472 + 26 ; // s ≤ 1498
int s_max = ( int ) ( link - > mtu ) - 3 - ( int ) SC_TAG_SIZE + ( int ) UDP_SC_HDR_SIZE ;
DEBUG_ERROR ( DEBUG_CATEGORY_CONNECTION , " INIT_RESP: mtu=%d s=%d s_max=%d xoffset=%d " , ( int ) link - > mtu , s , s_max , xoffset ) ;
if ( s > s_max ) { DEBUG_ERROR ( DEBUG_CATEGORY_CONNECTION , " INIT_RESP capped s=%d -> %d " , s , s_max ) ; s = s_max ; }
if ( s < 0 ) s = 0 ;
// Remove old hardcoded caps
// if (s > 1472 + 26) s = 1472 + 26;
int to_add = s - xoffset - UDP_HDR_SIZE - UDP_SC_HDR_SIZE ;
if ( to_add < 0 ) to_add = 0 ;