From e54738fc3ec42571274e5fc8aca76fcaaf3010c5 Mon Sep 17 00:00:00 2001
From: cellframe <roman.khlopkov@demlabs.net>
Date: Fri, 1 Jul 2022 15:34:09 +0300
Subject: [PATCH] [*] Master hotfix port

---
 .../block-ton/dap_chain_cs_block_ton.c          | 17 +++++++++--------
 modules/net/dap_chain_node_cli_cmd.c            |  2 +-
 2 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/modules/consensus/block-ton/dap_chain_cs_block_ton.c b/modules/consensus/block-ton/dap_chain_cs_block_ton.c
index 2348cffff0..f90ac21350 100644
--- a/modules/consensus/block-ton/dap_chain_cs_block_ton.c
+++ b/modules/consensus/block-ton/dap_chain_cs_block_ton.c
@@ -2189,16 +2189,17 @@ static void s_session_packet_in(void *a_arg, dap_chain_node_addr_t *a_sender_nod
 		} break;
 		case DAP_STREAM_CH_CHAIN_MESSAGE_TYPE_APPROVE: {
             if  ( sizeof(dap_chain_cs_block_ton_message_approve_t) >l_message_data_size  ){
-                log_it(L_WARNING, "Wrong reject message size,have %zu bytes for data section when requires %zu bytes",
+                log_it(L_WARNING, "Wrong approve message size,have %zu bytes for data section when requires %zu bytes",
                        l_message_data_size,sizeof(dap_chain_cs_block_ton_message_approve_t));
                 goto handler_finish;
             }
             dap_chain_cs_block_ton_message_approve_t *l_approve = (dap_chain_cs_block_ton_message_approve_t *) l_message_data;
             dap_sign_t * l_candidate_sign = (dap_sign_t *) l_approve->candidate_hash_sign;
+            size_t l_candidate_sign_size = dap_sign_get_size(l_candidate_sign);
             size_t l_candidate_hash_sign_size = l_message_data_size - sizeof(dap_chain_cs_block_ton_message_approve_t);
-            if (l_candidate_hash_sign_size || dap_sign_get_size(l_candidate_sign) > l_candidate_hash_sign_size ){
-                log_it(L_WARNING, "Wrong reject message size,have %zu bytes for candidate sign section when requires  maximum %zu bytes",
-                       dap_sign_get_size(l_candidate_sign),l_candidate_hash_sign_size);
+            if (l_candidate_sign_size > l_candidate_hash_sign_size) {
+                log_it(L_WARNING, "Wrong approve message size,have %zu bytes for candidate sign section when requires  maximum %zu bytes",
+                                   l_candidate_sign_size, l_candidate_hash_sign_size);
                 goto handler_finish;
             }
 
@@ -2315,7 +2316,7 @@ static void s_session_packet_in(void *a_arg, dap_chain_node_addr_t *a_sender_nod
         } break;
 		case DAP_STREAM_CH_CHAIN_MESSAGE_TYPE_VOTE: {
             if  ( sizeof(dap_chain_cs_block_ton_message_vote_t) >l_message_data_size  ){
-                log_it(L_WARNING, "Wrong vote_for message size,have %zu bytes for data section when requires %zu bytes",
+                log_it(L_WARNING, "Wrong vote message size,have %zu bytes for data section when requires %zu bytes",
                        l_message_data_size,sizeof(dap_chain_cs_block_ton_message_vote_t));
                 goto handler_finish;
             }
@@ -2422,9 +2423,9 @@ static void s_session_packet_in(void *a_arg, dap_chain_node_addr_t *a_sender_nod
             dap_sign_t * l_candidate_sign = (dap_sign_t *) l_commitsign->candidate_sign;
             size_t l_candidate_sign_size = dap_sign_get_size(l_candidate_sign);
             size_t l_message_candidate_sign_size_max = l_message_data_size - sizeof(dap_chain_cs_block_ton_message_commitsign_t);
-            if (l_message_candidate_sign_size_max == 0 || dap_sign_get_size(l_candidate_sign) > l_message_candidate_sign_size_max ){
-                log_it(L_WARNING, "Wrong reject message size,have %zu bytes for candidate sign section when requires  maximum %zu bytes",
-                       l_candidate_sign_size ,l_message_candidate_sign_size_max);
+            if (l_candidate_sign_size > l_message_candidate_sign_size_max ){
+                log_it(L_WARNING, "Wrong commit_sign message size,have %zu bytes for candidate sign section when requires  maximum %zu bytes",
+                                  l_candidate_sign_size, l_message_candidate_sign_size_max);
                 goto handler_finish;
             }
 
diff --git a/modules/net/dap_chain_node_cli_cmd.c b/modules/net/dap_chain_node_cli_cmd.c
index f466f0458c..dcf60f6e20 100644
--- a/modules/net/dap_chain_node_cli_cmd.c
+++ b/modules/net/dap_chain_node_cli_cmd.c
@@ -5175,7 +5175,7 @@ int cmd_gdb_import(int argc, char ** argv, char ** a_str_reply)
         if (dap_chain_global_db_driver_apply(l_group_store, l_records_count)) {
             log_it(L_CRITICAL, "An error occured on importing group %s...", l_group_name);
         } else {
-            log_it(L_INFO, "Imported %llu records of group %s", l_records_count, l_group_name);
+            log_it(L_INFO, "Imported %zu records of group %s", l_records_count, l_group_name);
         }
         //dap_store_obj_free(l_group_store, l_records_count);
     }
-- 
GitLab