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

+6 -6
View File
@@ -415,7 +415,7 @@ static void cs_start_channel_join(struct chat_sync* cs, uint64_t peer) {
/* ── Connection callbacks ── */
static void cs_on_conn_up(struct ETCP_CONN* conn, void* arg) {
static void cs_on_conn_up(struct ETCP_CONN* conn, int event, void* arg) { (void)event;
(void)arg;
if (!conn || !g_cs) return;
uint64_t peer = conn->peer_node_id;
@@ -438,7 +438,7 @@ static void cs_on_conn_up(struct ETCP_CONN* conn, void* arg) {
cs_on_peer_status_changed(peer, 1);
}
static void cs_on_conn_down(struct ETCP_CONN* conn, void* arg) {
static void cs_on_conn_down(struct ETCP_CONN* conn, int event, void* arg) { (void)event;
(void)arg;
if (!conn || !g_cs) return;
uint64_t peer = conn->peer_node_id;
@@ -467,8 +467,8 @@ static void cs_on_conn_down(struct ETCP_CONN* conn, void* arg) {
static void cs_on_conn_status(struct ETCP_CONN* conn, int status, void* arg) {
switch (status) {
case ETCP_CONN_STATUS_UP: cs_on_conn_up(conn, arg); break;
case ETCP_CONN_STATUS_DOWN: cs_on_conn_down(conn, arg); break;
case ETCP_CONN_STATUS_UP: cs_on_conn_up(conn, ETCP_CBK_EVENT_UP, arg); break;
case ETCP_CONN_STATUS_DOWN: cs_on_conn_down(conn, ETCP_CBK_EVENT_DOWN, arg); break;
default: break;
}
}
@@ -478,8 +478,8 @@ static void cs_on_new_conn(struct ETCP_CONN* conn, void* arg) {
(void)arg;
if (!conn) return;
DEBUG_TRACE(DEBUG_CATEGORY_DB_SYNC, "%s: new_conn conn=%p", CS_ID, (void*)conn);
etcp_conn_add_up_cbk(conn, cs_on_conn_up, NULL);
etcp_conn_add_down_cbk(conn, cs_on_conn_down, NULL);
etcp_conn_add_cbk(conn, cs_on_conn_up, NULL, ETCP_CBK_EVENT_UP);
etcp_conn_add_cbk(conn, cs_on_conn_down, NULL, ETCP_CBK_EVENT_DOWN);
}
#endif
+2 -2
View File
@@ -1089,10 +1089,10 @@ static void db_handle_sync_done(struct DB_SYNC_INSTANCE* si, uint64_t src, const
} else if (mc < pc) {
// Request tail
uint32_t vp_send = mc > 0 ? mc - 1 : (uint32_t)-1;
uint8_t req[14]; req[0] = DB_MSG_SEND_DATA;
uint8_t req[15]; req[0] = DB_MSG_SEND_DATA;
memcpy(req + 1, &mc, 4); uint16_t z = 0; memcpy(req + 5, &z, 2);
memcpy(req + 7, &vp_send, 4); memcpy(req + 11, &mc, 4);
db_sync_send(si, src, req, 14);
db_sync_send(si, src, req, 15);
if (sp) sp->sync_state = 1;
DEBUG_INFO(DEBUG_CATEGORY_DB_SYNC, "sync [%s:%04llX] ← SYNC_DONE: mc=%u < pc=%u → request tail from=%u",
SI_SHRT(si), (unsigned long long)(src >> 16), mc, pc, mc);