From 31c9ca8dab1e7f944b9ec10964814e4149c658f5 Mon Sep 17 00:00:00 2001
From: "roman.khlopkov" <roman.khlopkov@demlabs.net>
Date: Thu, 28 Mar 2024 22:19:18 +0300
Subject: [PATCH] [*] Bugfixes

---
 modules/channel/chain-net/dap_stream_ch_chain_net.c | 4 ++++
 modules/net/dap_chain_net.c                         | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/modules/channel/chain-net/dap_stream_ch_chain_net.c b/modules/channel/chain-net/dap_stream_ch_chain_net.c
index 056a573ce2..59c936263d 100644
--- a/modules/channel/chain-net/dap_stream_ch_chain_net.c
+++ b/modules/channel/chain-net/dap_stream_ch_chain_net.c
@@ -164,6 +164,10 @@ void s_stream_ch_packet_in(dap_stream_ch_t *a_ch, void* a_arg)
         }*/
         switch (l_ch_pkt->hdr.type) {
         case DAP_STREAM_CH_CHAIN_NET_PKT_TYPE_ANNOUNCE:
+            if (!a_ch->stream->authorized) {
+                log_it(L_WARNING, "Trying to announce net from not authorized stream");
+                break;
+            }
             assert(!dap_stream_node_addr_is_blank(&a_ch->stream->node));
             dap_accounting_downlink_in_net(l_net->pub.id.uint64, &a_ch->stream->node);
             break;
diff --git a/modules/net/dap_chain_net.c b/modules/net/dap_chain_net.c
index fbbcba3321..fcef844aa6 100644
--- a/modules/net/dap_chain_net.c
+++ b/modules/net/dap_chain_net.c
@@ -2031,7 +2031,7 @@ int s_net_init(const char *a_net_name, uint16_t a_acl_idx)
     }
     for (uint16_t i = 0; i < l_net_pvt->permanent_links_count; ++i) {
         l_net_pvt->permanent_links[i] = DAP_NEW_Z(dap_link_info_t);
-        if (l_net_pvt->permanent_links[i]) {
+        if (!l_net_pvt->permanent_links[i]) {
             log_it(L_CRITICAL, "%s", g_error_memory_alloc);
             dap_chain_net_delete(l_net);
             dap_config_close(l_cfg);
-- 
GitLab