diff options
author | Alexander Blair <snipa@jagtech.io> | 2020-02-28 20:20:41 -0800 |
---|---|---|
committer | Alexander Blair <snipa@jagtech.io> | 2020-02-28 20:21:06 -0800 |
commit | da617ac1b0856eca5b5e94e4bc2b6c64575013b2 (patch) | |
tree | fa439893f892141ea4902bde130262b6a5b2671e /src/wallet/wallet2.cpp | |
parent | Merge pull request #6222 (diff) | |
parent | wallet2: guard against race with multiple decrypt_keys users (diff) | |
download | monero-da617ac1b0856eca5b5e94e4bc2b6c64575013b2.tar.xz |
Merge pull request #6238
f717d593 wallet2: guard against race with multiple decrypt_keys users (moneromooo-monero)
Diffstat (limited to 'src/wallet/wallet2.cpp')
-rw-r--r-- | src/wallet/wallet2.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index d3349d58b..0faa5d1aa 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -1186,6 +1186,7 @@ wallet2::wallet2(network_type nettype, uint64_t kdf_rounds, bool unattended): m_ringdb(), m_last_block_reward(0), m_encrypt_keys_after_refresh(boost::none), + m_decrypt_keys_lockers(0), m_unattended(unattended), m_devices_registered(false), m_device_last_key_image_sync(0), @@ -4371,12 +4372,18 @@ bool wallet2::verify_password(const std::string& keys_file_name, const epee::wip void wallet2::encrypt_keys(const crypto::chacha_key &key) { + boost::lock_guard<boost::mutex> lock(m_decrypt_keys_lock); + if (--m_decrypt_keys_lockers) // another lock left ? + return; m_account.encrypt_keys(key); m_account.decrypt_viewkey(key); } void wallet2::decrypt_keys(const crypto::chacha_key &key) { + boost::lock_guard<boost::mutex> lock(m_decrypt_keys_lock); + if (m_decrypt_keys_lockers++) // already unlocked ? + return; m_account.encrypt_viewkey(key); m_account.decrypt_keys(key); } |