From 781ac1e3572bbcf8485efa59081efc55d8f9a377 Mon Sep 17 00:00:00 2001 From: "alexey.stratulat" <alexey.stratulat@demlabs.net> Date: Fri, 29 Nov 2024 10:33:14 +0000 Subject: [PATCH] Port 14244 --- dap-sdk | 2 +- modules/node-cli/dap_chain_node_cli_cmd.c | 13 +++++++++++++ modules/node-cli/include/dap_chain_node_cli_cmd.h | 1 + modules/type/blocks/dap_chain_cs_blocks.c | 2 +- 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/dap-sdk b/dap-sdk index ae86be55cb..52deff6c95 160000 --- a/dap-sdk +++ b/dap-sdk @@ -1 +1 @@ -Subproject commit ae86be55cbf985137a9117ce7960704e165011e4 +Subproject commit 52deff6c95aadf30957b828ef68c8814195fe825 diff --git a/modules/node-cli/dap_chain_node_cli_cmd.c b/modules/node-cli/dap_chain_node_cli_cmd.c index d3a678c518..3a75f1c323 100644 --- a/modules/node-cli/dap_chain_node_cli_cmd.c +++ b/modules/node-cli/dap_chain_node_cli_cmd.c @@ -2054,6 +2054,12 @@ int l_arg_index = 1, l_rc, cmd_num = CMD_NONE; json_object_put(json_arr_out); return DAP_CHAIN_NODE_CLI_COM_TX_WALLET_CONVERT_ERR; } + if (l_pass_str && !dap_check_valid_password(l_pass_str, dap_strlen(l_pass_str))) { + dap_json_rpc_error_add(*a_json_arr_reply, + DAP_CHAIN_NODE_CLI_COM_TX_WALLET_INVALID_CHARACTERS_USED_FOR_PASSWORD, + "Invalid characters used for password."); + return DAP_CHAIN_NODE_CLI_COM_TX_WALLET_INVALID_CHARACTERS_USED_FOR_PASSWORD; + } // create wallet backup dap_chain_wallet_internal_t* l_file_name = DAP_CHAIN_WALLET_INTERNAL(l_wallet); snprintf(l_file_name->file_name, sizeof(l_file_name->file_name) - 1, "%s/%s_%012lu%s", c_wallets_path, l_wallet_name, time(NULL),".backup"); @@ -2185,6 +2191,13 @@ int l_arg_index = 1, l_rc, cmd_num = CMD_NONE; return DAP_CHAIN_NODE_CLI_COM_TX_WALLET_HASH_ERR; } } + // Checking that if a password is set, it contains only Latin characters, numbers and special characters, except for spaces. + if (l_pass_str && !dap_check_valid_password(l_pass_str, dap_strlen(l_pass_str))) { + dap_json_rpc_error_add(*a_json_arr_reply, + DAP_CHAIN_NODE_CLI_COM_TX_WALLET_INVALID_CHARACTERS_USED_FOR_PASSWORD, + "Invalid characters used for password."); + return DAP_CHAIN_NODE_CLI_COM_TX_WALLET_INVALID_CHARACTERS_USED_FOR_PASSWORD; + } // Creates new wallet l_wallet = dap_chain_wallet_create_with_seed_multi(l_wallet_name, c_wallets_path, l_sign_types, l_sign_count, diff --git a/modules/node-cli/include/dap_chain_node_cli_cmd.h b/modules/node-cli/include/dap_chain_node_cli_cmd.h index 6ac1793647..4f0c5d6321 100644 --- a/modules/node-cli/include/dap_chain_node_cli_cmd.h +++ b/modules/node-cli/include/dap_chain_node_cli_cmd.h @@ -158,6 +158,7 @@ typedef enum s_com_tx_wallet_err{ DAP_CHAIN_NODE_CLI_COM_TX_WALLET_CHAIN_PARAM_ERR, DAP_CHAIN_NODE_CLI_COM_TX_WALLET_INTERNAL_ERR, DAP_CHAIN_NODE_CLI_COM_TX_WALLET_CAN_NOT_GET_ADDR, + DAP_CHAIN_NODE_CLI_COM_TX_WALLET_INVALID_CHARACTERS_USED_FOR_PASSWORD, /* add custom codes here */ diff --git a/modules/type/blocks/dap_chain_cs_blocks.c b/modules/type/blocks/dap_chain_cs_blocks.c index 18a1a409e9..b13fb6e498 100644 --- a/modules/type/blocks/dap_chain_cs_blocks.c +++ b/modules/type/blocks/dap_chain_cs_blocks.c @@ -965,7 +965,7 @@ static int s_cli_blocks(int a_argc, char ** a_argv, void **a_str_reply) if (l_from_time && l_ts < l_from_time) continue; if (l_to_time && l_ts >= l_to_time) - break; + continue; if (l_from_hash_str && !l_hash_flag) { if (!dap_hash_fast_compare(&l_from_hash, &l_block_cache->block_hash)) continue; -- GitLab