fix: memory pool alloc mismatch in tests, db_sync SEND_DATA buffer overflow

- test_etcp_router_reconnect, test_etcp_connect, test_stcp_traffic:
  replace u_calloc with memory_pool_alloc for TOPO_SOCKMETA4/TOPO_ADDR4
- db_sync.c: fix req[14] -> req[15] — SEND_DATA request header is 15 bytes
  (type:1 + from:4 + count:2 + vp:4 + want_from:4)
This commit is contained in:
evgeny committed 2026-07-31 21:44:44 +03:00
1 parent fe9be74e29
commit d310bccf08
52 files changed
+1796 -585

No files matched your search

+8 -6
View File
@@ -101,7 +101,7 @@ static void send_debug_config(struct control_server* server, struct control_clie
static void send_error(struct control_client* client, uint8_t error_code, const char* msg, uint8_t seq_id);
static void control_server_send_node_list(struct control_server* server, struct control_client* client, uint8_t seq_id);
static void send_single_node_info(struct control_server* server, struct control_client* client, struct TOPO_NODEQ* nq);
static void send_single_node_info(struct control_server* server, struct control_client* client, struct TOPO_GROUP_NODE* nq);
static int control_client_send(struct control_server* server, struct control_client* client, uint8_t* dgram, uint16_t len);
static struct ETCP_CONN* find_connection_by_peer_id(struct UTUN_INSTANCE* instance, uint64_t peer_id);
@@ -1385,10 +1385,12 @@ static struct ETCP_CONN* find_connection_by_peer_id(struct UTUN_INSTANCE* instan
* Node Info Helpers (send_single_node_info, send_node_list, notify_change)
* ============================================================================ */
static void send_single_node_info(struct control_server* server, struct control_client* client, struct TOPO_NODEQ* nq) {
if (!server || !nq || !nq->node) return;
static void send_single_node_info(struct control_server* server, struct control_client* client, struct TOPO_GROUP_NODE* nq) {
if (!server || !nq) return;
struct TOPO_NODE* ni = topo_node_registry_find(server->instance->topo_groups, nq->node_id);
if (!ni) return;
uint8_t buf[8192];
int ser_len = topo_node_serialize(topo_groups_get_default(server->instance->topo_groups), nq, buf + 2, sizeof(buf) - 2, 0);
int ser_len = topo_node_serialize(ni, nq, buf + 2, sizeof(buf) - 2, 0);
if (ser_len < 0) { DEBUG_ERROR(DEBUG_CATEGORY_CONTROL, "Failed to serialize node info"); return; }
buf[0] = CTRL_BGP_CMD; buf[1] = CTRL_BGP_SUBCMD;
size_t data_size = 2 + (size_t)ser_len;
@@ -1414,7 +1416,7 @@ static void control_server_send_node_list(struct control_server* server, struct
/* Send all known remote nodes */
struct ll_entry* e = group->nodes ? group->nodes->head : NULL;
while (e) {
struct TOPO_NODEQ* nq = (struct TOPO_NODEQ*)e;
struct TOPO_GROUP_NODE* nq = (struct TOPO_GROUP_NODE*)e;
send_single_node_info(server, client, nq);
e = e->next;
}
@@ -1429,7 +1431,7 @@ static void control_server_send_node_list(struct control_server* server, struct
DEBUG_INFO(DEBUG_CATEGORY_CONTROL, "Sent node list to client (seq=%d)", seq_id);
}
void control_server_notify_node_change(struct control_server* server, struct TOPO_NODEQ* node) {
void control_server_notify_node_change(struct control_server* server, struct TOPO_GROUP_NODE* node) {
if (!server || !node) return;
struct control_client* client = server->clients;
while (client) {