Guard mesh gate node indices before matching endpoints

This commit is contained in:
evgeny committed 2026-10-26 15:09:35 +01:00
1 parent 1bc27aa2ca
commit bf4d14c46e
1 file changed
+3 -2
+3 -2
View File
@@ -130,7 +130,8 @@ static void mesh_radio_recv(struct ETCP_CONN* conn, struct ll_entry* entry) {
int self = mesh_node_index(conn->instance->node_id), peer = mesh_node_index(conn->peer_node_id);
mesh_wire("RX", conn, entry);
g_radio_recv(conn, entry);
if (self == g_hold_node && peer == IDX_C && g_rx[self].frames == N_FRAMES && g_rx[self].fin_seen && !g_released) {
if (g_hold_node >= 0 && self == g_hold_node && peer == IDX_C
&& g_rx[self].frames == N_FRAMES && g_rx[self].fin_seen && !g_released) {
if (g_held_count != N_FRAMES + 1) {
DEBUG_ERROR(DEBUG_CATEGORY_DEBUG, "mesh gate: incomplete held burst node=%s held=%u", g_names[self], g_held_count);
abort();
@@ -162,7 +163,7 @@ int __wrap_etcp_bind(struct UTUN_INSTANCE* inst, uint8_t id, etcp_recv_fn callba
int __wrap_etcp_send(struct ETCP_CONN* conn, struct ll_entry* entry) {
mesh_wire("TX", conn, entry);
if (conn && entry && entry->len >= 1 + RADIO_HDR_SIZE && entry->dgram[0] == ETCP_ID_RADIO
if (g_hold_node >= 0 && conn && entry && entry->len >= 1 + RADIO_HDR_SIZE && entry->dgram[0] == ETCP_ID_RADIO
&& conn->instance->node_id == g_sh.nid[IDX_A] && mesh_node_index(conn->peer_node_id) == g_hold_node && !g_released) {
if (g_held_count == N_FRAMES + 1) {
DEBUG_ERROR(DEBUG_CATEGORY_DEBUG, "mesh gate: held burst overflow node=%s", g_names[g_hold_node]); abort();