diff --git a/dap-sdk b/dap-sdk index 08250a34c8c40afb400b5e734dc7097e38a234d3..34ea33894637309e6853b4f69c463523d82651b2 160000 --- a/dap-sdk +++ b/dap-sdk @@ -1 +1 @@ -Subproject commit 08250a34c8c40afb400b5e734dc7097e38a234d3 +Subproject commit 34ea33894637309e6853b4f69c463523d82651b2 diff --git a/modules/net/dap_chain_node_cli_cmd.c b/modules/net/dap_chain_node_cli_cmd.c index 219a07b85ce7aab76d5aab715ba9bcacc1c2e3ef..e5f48a323fffb0a65f0dc299780744aad5565606 100644 --- a/modules/net/dap_chain_node_cli_cmd.c +++ b/modules/net/dap_chain_node_cli_cmd.c @@ -2155,6 +2155,12 @@ char l_buf[1024]; return -EINVAL; } + if ( DAP_WALLET$SZ_PASS < strnlen(l_pass_str, DAP_WALLET$SZ_PASS + 1) ) { + dap_cli_server_cmd_set_reply_text(a_str_reply, "Wallet's password is too long ( > %d)", DAP_WALLET$SZ_PASS); + log_it(L_ERROR, "Wallet's password is too long ( > %d)", DAP_WALLET$SZ_PASS); + return -EINVAL; + } + l_wallet = dap_chain_wallet_open(l_wallet_name, c_wallets_path); if (!l_wallet) { dap_cli_server_cmd_set_reply_text(a_str_reply, "wrong password"); @@ -2165,10 +2171,10 @@ char l_buf[1024]; } // create wallet backup dap_chain_wallet_internal_t* l_file_name = DAP_CHAIN_WALLET_INTERNAL(l_wallet); - time_t rawtime; // add timestamp to filename + time_t l_rawtime; // add timestamp to filename char l_timestamp[16]; - time(&rawtime); - strftime(l_timestamp,16,"%G%m%d%H%M%S", localtime (&rawtime)); + time(&l_rawtime); + strftime(l_timestamp,16,"%G%m%d%H%M%S", localtime (&l_rawtime)); snprintf(l_file_name->file_name, sizeof(l_file_name->file_name) - 1, "%s/%s_%s%s", c_wallets_path, l_wallet_name, l_timestamp,".backup"); if ( dap_chain_wallet_save(l_wallet, NULL) ) { dap_cli_server_cmd_set_reply_text(a_str_reply, "Can't create backup wallet file because of internal error"); diff --git a/modules/wallet/dap_chain_wallet.c b/modules/wallet/dap_chain_wallet.c index 1c02e0be223b8dbb2f77526aa8032f26dd13cc27..b3dbc6749120c8137ac7ca2153619e306bddb20d 100644 --- a/modules/wallet/dap_chain_wallet.c +++ b/modules/wallet/dap_chain_wallet.c @@ -388,13 +388,12 @@ dap_chain_wallet_t * dap_chain_wallet_create_with_seed ( { dap_chain_wallet_t *l_wallet; dap_chain_wallet_internal_t *l_wallet_internal; -int l_rc, l_wallet_name_len, l_pass_len; /* Sanity checks ... */ - if ( DAP_WALLET$SZ_NAME < (l_wallet_name_len = strnlen(a_wallet_name, DAP_WALLET$SZ_NAME + 1)) ) + if (a_wallet_name && DAP_WALLET$SZ_NAME < strnlen(a_wallet_name, DAP_WALLET$SZ_NAME + 1) ) return log_it(L_ERROR, "Wallet's name is too long ( > %d)", DAP_WALLET$SZ_NAME), NULL; - if ( DAP_WALLET$SZ_PASS < (l_pass_len = strnlen(a_wallet_name, DAP_WALLET$SZ_PASS + 1)) ) + if ( a_pass && DAP_WALLET$SZ_PASS < strnlen(a_pass, DAP_WALLET$SZ_PASS + 1) ) return log_it(L_ERROR, "Wallet's password is too long ( > %d)", DAP_WALLET$SZ_PASS), NULL; if ( !(l_wallet = DAP_NEW_Z(dap_chain_wallet_t)) ) @@ -412,7 +411,7 @@ int l_rc, l_wallet_name_len, l_pass_len; l_wallet_internal->certs[0] = dap_cert_generate_mem_with_seed(a_wallet_name, dap_sign_type_to_key_type(a_sig_type), a_seed, a_seed_size); - if ( !(l_rc = dap_chain_wallet_save(l_wallet, a_pass)) ) + if ( !dap_chain_wallet_save(l_wallet, a_pass) ) { log_it(L_INFO, "Wallet %s has been created (%s)", a_wallet_name, l_wallet_internal->file_name); return l_wallet;