From de227a31150db9d5e87bc5527d9e091de3d517a0 Mon Sep 17 00:00:00 2001 From: pkova Date: Tue, 15 Apr 2025 13:26:24 +0300 Subject: [PATCH 1/4] ames: do not leak fine response packet --- pkg/vere/io/ames.c | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/vere/io/ames.c b/pkg/vere/io/ames.c index d6d03df010..c9f035b5aa 100644 --- a/pkg/vere/io/ames.c +++ b/pkg/vere/io/ames.c @@ -1935,6 +1935,7 @@ _fine_hear_response(u3_pact* pac_u, c3_w cur_w) u3_auto_plan(&pac_u->sam_u->car_u, ovo_u); _ames_cap_queue(pac_u->sam_u); + _ames_pact_free(pac_u); } /* _ames_hear_ames(): hear ames packet. From 677955d79e3362108602af940ac5df0dccc1f74c Mon Sep 17 00:00:00 2001 From: pkova Date: Tue, 15 Apr 2025 13:27:26 +0300 Subject: [PATCH 2/4] mesa: close udp receive handle in _mesa_io_exit --- pkg/vere/io/mesa.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkg/vere/io/mesa.c b/pkg/vere/io/mesa.c index cbcc170986..529c367dc2 100644 --- a/pkg/vere/io/mesa.c +++ b/pkg/vere/io/mesa.c @@ -1811,7 +1811,9 @@ _mesa_io_exit(u3_auto* car_u) u3_mesa* sam_u = (u3_mesa*)car_u; uv_timer_stop(&sam_u->tim_u); sam_u->tim_u.data = sam_u; + uv_udp_recv_stop(&u3_Host.wax_u); uv_close((uv_handle_t*)&sam_u->tim_u, _mesa_exit_cb); + uv_close((uv_handle_t*)&u3_Host.wax_u, 0); } static void From be8b50af7fee7c36f78afed65d1077bd1d4e68c2 Mon Sep 17 00:00:00 2001 From: pkova Date: Tue, 15 Apr 2025 14:10:23 +0300 Subject: [PATCH 3/4] mesa: only ever use HOP_SHORT and HOP_NONE --- pkg/vere/io/mesa.c | 23 +++-------------------- pkg/vere/io/mesa/pact.c | 23 ++--------------------- 2 files changed, 5 insertions(+), 41 deletions(-) diff --git a/pkg/vere/io/mesa.c b/pkg/vere/io/mesa.c index 529c367dc2..73bc84e2b0 100644 --- a/pkg/vere/io/mesa.c +++ b/pkg/vere/io/mesa.c @@ -2429,26 +2429,9 @@ _mesa_add_hop(c3_y hop_y, u3_mesa_head* hed_u, u3_mesa_page_pact* pag_u, sockadd { c3_w pip_w = ntohl(lan_u.sin_addr.s_addr); c3_s por_s = ntohs(lan_u.sin_port); - if ( 1 == hop_y ) { - c3_etch_word(pag_u->sot_u, pip_w); - c3_etch_short(pag_u->sot_u + 4, por_s); - hed_u->nex_y = HOP_SHORT; - return; - } - - - u3_mesa_hop_once* lan_y = c3_calloc(sizeof(u3_mesa_hop_once)); - - c3_etch_word(lan_y->dat_y, pip_w); - c3_etch_short(lan_y->dat_y, por_s); - - lan_y->len_w = 6; - - c3_realloc(&pag_u->man_u, pag_u->man_u.len_w + 8); - pag_u->man_u.dat_y[pag_u->man_u.len_w] = *lan_y; - - pag_u->man_u.len_w++; - + c3_etch_word(pag_u->sot_u, pip_w); + c3_etch_short(pag_u->sot_u + 4, por_s); + hed_u->nex_y = HOP_SHORT; } /* static c3_d avg_time() { */ diff --git a/pkg/vere/io/mesa/pact.c b/pkg/vere/io/mesa/pact.c index 67ae58df3a..1b2940c2be 100644 --- a/pkg/vere/io/mesa/pact.c +++ b/pkg/vere/io/mesa/pact.c @@ -395,14 +395,6 @@ _sift_bytes(u3_sifter* sif_u, c3_y *buf_y, c3_w len_w) memcpy(buf_y, res_y, len_w); } -static c3_y* -_sift_bytes_alloc(u3_sifter* sif_u, c3_w len_w) -{ - c3_y *buf_y = c3_calloc(len_w); - _sift_bytes(sif_u, buf_y, len_w); - return buf_y; -} - static void _etch_byte(u3_etcher* ech_u, c3_y val_y) { @@ -762,13 +754,6 @@ _mesa_etch_hop_long(u3_etcher* ech_u, u3_mesa_hop_once* hop_u) _etch_bytes(ech_u, hop_u->dat_y, hop_u->len_w); } -static void -_mesa_sift_hop_long(u3_sifter* sif_u, u3_mesa_hop_once* hop_u) -{ - hop_u->len_w = _sift_byte(sif_u); - hop_u->dat_y = _sift_bytes_alloc(sif_u, hop_u->len_w); -} - static void _mesa_etch_page_pact(u3_etcher* ech_u, u3_mesa_page_pact* pag_u, u3_mesa_head* hed_u) { @@ -812,15 +797,11 @@ _mesa_sift_page_pact(u3_sifter* sif_u, u3_mesa_page_pact* pag_u, c3_y nex_y) return; } case HOP_LONG: { - _mesa_sift_hop_long(sif_u, &pag_u->one_u); + _sift_fail(sif_u, "mesa: sift invalid hop long"); return; } case HOP_MANY: { - pag_u->man_u.len_w = _sift_byte(sif_u); - pag_u->man_u.dat_y = c3_calloc(sizeof(u3_mesa_hop_once) * pag_u->man_u.len_w); - for ( c3_w i = 0; i < pag_u->man_u.len_w; i++ ) { - _mesa_sift_hop_long(sif_u, &pag_u->man_u.dat_y[i]); - } + _sift_fail(sif_u, "mesa: sift invalid hop many"); return; } } From 3e6a766b85c0b6b5e36081a9acd64e79f4123c81 Mon Sep 17 00:00:00 2001 From: pkova Date: Tue, 15 Apr 2025 14:20:02 +0300 Subject: [PATCH 4/4] mesa: do not early return from pit, we might also be interested --- pkg/vere/io/mesa.c | 1 - 1 file changed, 1 deletion(-) diff --git a/pkg/vere/io/mesa.c b/pkg/vere/io/mesa.c index 73bc84e2b0..4d21bd209c 100644 --- a/pkg/vere/io/mesa.c +++ b/pkg/vere/io/mesa.c @@ -2546,7 +2546,6 @@ _mesa_hear_page(u3_mesa_pict* pic_u, sockaddr_in lan_u) _mesa_send_pact(sam_u, pin_u->adr_u, NULL, pac_u); _mesa_del_pit(sam_u, nam_u); - return; } c3_d lev_d = mesa_num_leaves(pac_u->pag_u.dat_u.tob_d);