@ -1366,11 +1366,11 @@ static int etcp_send_ping_raw(struct ETCP_DGRAM* dgram, struct ETCP_SOCKET* e_so
return - 1 ;
}
int len = dgram - > data_len - dgram - > noencrypt_len ;
if ( len < 0 | | len > PACKET_DATA_SIZE - IP_UDP_OVERHEAD_V4 ) {
DEBUG_ERROR ( DEBUG_CATEGORY_ETCP , " ping packet data invalid len=%d " , len ) ;
uint8_t enc_buf [ 1600 ] ;
if ( len < 0 | | len + ( int ) dgram - > noencrypt_len + SC_ENCRYPT_OVERHEAD > ( int ) sizeof ( enc_buf ) ) {
DEBUG_ERROR ( DEBUG_CATEGORY_ETCP , " ping packet too large len=%d ne=%d " , len , dgram - > noencrypt_len ) ;
return - 1 ;
}
uint8_t enc_buf [ 1600 ] ;
size_t enc_buf_len = 0 ;
dgram - > timestamp = get_current_timestamp ( ) ;
dgram - > flag_up = 1 ;
@ -1477,7 +1477,7 @@ int etcp_send_ping_to_socket(struct UTUN_INSTANCE* instance, struct ETCP_SOCKET*
ctx - > user_data_len = user_data_len ;
}
memcpy ( ctx - > peer_pubkey , peer_pubkey_bin , SC_PUBKEY_SIZE ) ;
struct ETCP_DGRAM * dgram = u_malloc ( PACKET_DATA_SIZE ) ;
struct ETCP_DGRAM * dgram = u_malloc ( sizeof ( struct ETCP_DGRAM ) + PACKET_DATA_SIZE ) ;
if ( ! dgram ) {
if ( ctx - > user_data ) u_free ( ctx - > user_data ) ;
u_free ( ctx ) ;
@ -1629,6 +1629,7 @@ static int handle_ping(struct ETCP_SOCKET* e_sock, struct ETCP_DGRAM* pkt, const
uint64_t peer_id = be64toh ( * ( uint64_t * ) ( pkt - > data + 2 ) ) ;
uint64_t nonce = be64toh ( * ( uint64_t * ) ( pkt - > data + 10 ) ) ;
uint16_t ulen = be16toh ( * ( uint16_t * ) ( pkt - > data + 18 ) ) ;
if ( ulen > pkt - > data_len - 20 ) ulen = ( uint16_t ) ( pkt - > data_len - 20 ) ;
const uint8_t * udata = ( ulen > 0 ) ? ( pkt - > data + 20 ) : NULL ;
if ( ( flags & ETCP_PING_FLAG_SEND_RTT ) & & ulen > = 2 ) {
@ -1641,7 +1642,7 @@ static int handle_ping(struct ETCP_SOCKET* e_sock, struct ETCP_DGRAM* pkt, const
if ( e_sock - > instance - > topo_groups & & topo_node_ping_request_cbk ( e_sock - > instance - > topo_groups , peer_id ) )
pong_flags | = ETCP_PING_FLAG_WANT_RTT ;
struct ETCP_DGRAM * resp = u_malloc ( PACKET_DATA_SIZE ) ;
struct ETCP_DGRAM * resp = u_malloc ( sizeof ( struct ETCP_DGRAM ) + PACKET_DATA_SIZE ) ;
if ( resp ) {
resp - > link = NULL ;
resp - > noencrypt_len = SC_PUBKEY_ENC_SIZE ;