Browse Source

fix elementary format string bugs in log messages

- etcp.c:466: %d→%s for log_name (was printing garbage like -2012603448)
- etcp_connections.c:2235: Server type %d→%s with server_type_str()
- etcp_connections.c:845,1578,1587: type=%d/nat_type=%d→%s with helpers
topo_upd
evgeny 2 months ago
parent
commit
513ec75c28
  1. 2
      src/transport_layer/etcp.c
  2. 14
      src/transport_layer/etcp_connections.c

2
src/transport_layer/etcp.c

@ -463,7 +463,7 @@ void etcp_conn_ref_free(struct ETCP_CONN* conn) {
// Reset connection
void etcp_conn_reset(struct ETCP_CONN* etcp) {
// Reset IDs
DEBUG_WARN(DEBUG_CATEGORY_ETCP, "Resetting ETCP instance [%d]", etcp->log_name);
DEBUG_WARN(DEBUG_CATEGORY_ETCP, "Resetting ETCP instance [%s]", etcp->log_name);
etcp->next_tx_id = 1;
etcp->last_rx_id = 0;
etcp->last_delivered_id = 0;

14
src/transport_layer/etcp_connections.c

@ -842,8 +842,8 @@ struct TCP_SOCKET* tcp_socket_add(struct UTUN_INSTANCE* instance, struct CFG_SER
{ char loc_str[64] = "none", if_str[64] = "none";
if (ts->local_addr.ss_family) snprintf(loc_str, sizeof(loc_str), "%s", sockaddr_storage_to_str(&ts->local_addr).str);
if (ts->interface_addr.ss_family) snprintf(if_str, sizeof(if_str), "%s", sockaddr_storage_to_str(&ts->interface_addr).str);
DEBUG_INFO(DEBUG_CATEGORY_SOCKET, "tcp_socket_add: %s type=%d sock_id=%u local=%s iface=%s",
ts->name, ts->type, ts->sock_id, loc_str, if_str); }
DEBUG_INFO(DEBUG_CATEGORY_SOCKET, "tcp_socket_add: %s type=%s sock_id=%u local=%s iface=%s",
ts->name, server_type_str(ts->type), ts->sock_id, loc_str, if_str); }
return ts;
}
@ -1575,8 +1575,8 @@ static int handle_init_response_client(struct ETCP_SOCKET* e_sock, struct ETCP_D
// Update socket NAT address (only if not already verified)
{
DEBUG_INFO(DEBUG_CATEGORY_NAT, "init_resp nat: socket=%s nat_type=%d new_ip=%s new_port=%u",
e_sock->name, e_sock->nat_type,
DEBUG_INFO(DEBUG_CATEGORY_NAT, "init_resp nat: socket=%s nat=%s new_ip=%s new_port=%u",
e_sock->name, nat_type_str(e_sock->nat_type),
ip_to_str(&new_nat_ip, AF_INET).str, new_nat_port);
if (e_sock->nat_type < NAT_VERIFIED_UNKNOWN) {
struct sockaddr_in* sin = (struct sockaddr_in*)&e_sock->nat_addr;
@ -1584,8 +1584,8 @@ static int handle_init_response_client(struct ETCP_SOCKET* e_sock, struct ETCP_D
sin->sin_addr.s_addr = new_nat_ip;
sin->sin_port = htons(new_nat_port);
} else {
DEBUG_INFO(DEBUG_CATEGORY_NAT, "init_resp nat update SKIPPED (already verified): socket=%s nat_type=%d",
e_sock->name, e_sock->nat_type);
DEBUG_INFO(DEBUG_CATEGORY_NAT, "init_resp nat update SKIPPED (already verified): socket=%s nat=%s",
e_sock->name, nat_type_str(e_sock->nat_type));
}
}
} else {
@ -2232,7 +2232,7 @@ int init_sockets(struct UTUN_INSTANCE* instance) {
if (server->ip.ss_family == AF_INET) {
struct in_addr addr;
addr.s_addr = default_ip;
DEBUG_INFO(DEBUG_CATEGORY_ETCP, "Server %s type %d ip=%s", server->name, server->type, ip_to_str(&addr, AF_INET).str);
DEBUG_INFO(DEBUG_CATEGORY_ETCP, "Server %s type=%s ip=%s", server->name, server_type_str(server->type), ip_to_str(&addr, AF_INET).str);
}
}
if (e_sock && have_default_ip6) {

Loading…
Cancel
Save