From cc08086cacc284b6601325a742dcdebbb1a3692c Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Tue, 1 Dec 2020 19:28:41 +0100 Subject: [PATCH] fixed errors on get_seed_phrase_info --- src/currency_core/account.cpp | 20 ++++++++++++++++++-- src/wallet/wallet_helpers.h | 10 +++++++++- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/src/currency_core/account.cpp b/src/currency_core/account.cpp index 2494f056..117874ca 100644 --- a/src/currency_core/account.cpp +++ b/src/currency_core/account.cpp @@ -159,14 +159,30 @@ namespace currency uint64_t auditable_flag_and_checksum = UINT64_MAX; if (!auditable_flag_and_checksum_word.empty()) - auditable_flag_and_checksum = tools::mnemonic_encoding::num_by_word(auditable_flag_and_checksum_word); + { + try { + auditable_flag_and_checksum = tools::mnemonic_encoding::num_by_word(auditable_flag_and_checksum_word); + } + catch (...) + { + return false; + } + + } + std::vector keys_seed_binary = tools::mnemonic_encoding::text2binary(keys_seed_text); std::vector keys_seed_processed_binary = keys_seed_binary; bool has_password = false; - m_creation_timestamp = get_timstamp_from_word(timestamp_word, has_password); + try { + m_creation_timestamp = get_timstamp_from_word(timestamp_word, has_password); + } + catch (...) + { + return false; + } //double check is password setting from timestamp word match with passed parameters CHECK_AND_ASSERT_MES(has_password != seed_password.empty(), false, "Seed phrase password wrong interpretation"); if (has_password) diff --git a/src/wallet/wallet_helpers.h b/src/wallet/wallet_helpers.h index e4cee938..2ecfa778 100644 --- a/src/wallet/wallet_helpers.h +++ b/src/wallet/wallet_helpers.h @@ -27,7 +27,15 @@ namespace tools inline std::string get_seed_phrase_info(const std::string& seed_phrase, const std::string& seed_password, view::seed_phrase_info& result) { //cut the last timestamp word from restore_dats - result.syntax_correct = currency::account_base::is_seed_password_protected(seed_phrase, result.require_password); + try{ + result.syntax_correct = currency::account_base::is_seed_password_protected(seed_phrase, result.require_password); + } + catch (...) + { + result.syntax_correct = false; + return API_RETURN_CODE_OK; + } + if (result.syntax_correct) { currency::account_base acc;