diff options
author | George Hazan <ghazan@miranda.im> | 2020-02-07 19:46:11 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2020-02-07 19:46:11 +0300 |
commit | 5c4715aea7dc5bda704924448d2d74380f75c0b0 (patch) | |
tree | bdff3c35d07634b67efe9ab8514b761ad6c2a565 /plugins/Dbx_mdbx/src/dbcrypt.cpp | |
parent | 3c7699f80c5c4b8be13731c36d4deb4c6cc8eefe (diff) |
fixes #2205 (Unable to create new profile)
Diffstat (limited to 'plugins/Dbx_mdbx/src/dbcrypt.cpp')
-rw-r--r-- | plugins/Dbx_mdbx/src/dbcrypt.cpp | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/plugins/Dbx_mdbx/src/dbcrypt.cpp b/plugins/Dbx_mdbx/src/dbcrypt.cpp index 8cdc884c6f..75a630aa72 100644 --- a/plugins/Dbx_mdbx/src/dbcrypt.cpp +++ b/plugins/Dbx_mdbx/src/dbcrypt.cpp @@ -202,11 +202,15 @@ int CDbxMDBX::InitCrypt() if (m_crypto != nullptr)
return 0;
- txn_ptr_ro txn(m_txn_ro);
+ int rc;
+ MDBX_val key = { DBKey_Crypto_Provider, sizeof(DBKey_Crypto_Provider) }, value;
+ {
+ txn_ptr_ro txn(m_txn_ro);
+ rc = mdbx_get(txn, m_dbCrypto, &key, &value);
+ }
CRYPTO_PROVIDER *pProvider;
- MDBX_val key = { DBKey_Crypto_Provider, sizeof(DBKey_Crypto_Provider) }, value;
- if (mdbx_get(txn, m_dbCrypto, &key, &value) == MDBX_SUCCESS) {
+ if (rc == MDBX_SUCCESS) {
pProvider = Crypto_GetProvider((const char*)value.iov_base);
if (pProvider == nullptr)
pProvider = SelectProvider();
@@ -220,7 +224,12 @@ int CDbxMDBX::InitCrypt() return 3;
key.iov_len = sizeof(DBKey_Crypto_Key); key.iov_base = DBKey_Crypto_Key;
- if (mdbx_get(txn, m_dbCrypto, &key, &value) == MDBX_SUCCESS && (value.iov_len == m_crypto->getKeyLength())) {
+ {
+ txn_ptr_ro txn(m_txn_ro);
+ rc = mdbx_get(txn, m_dbCrypto, &key, &value);
+ }
+
+ if (rc == MDBX_SUCCESS && (value.iov_len == m_crypto->getKeyLength())) {
if (!m_crypto->setKey((const BYTE*)value.iov_base, value.iov_len)) {
CEnterPasswordDialog dlg(this);
while (true) {
@@ -243,11 +252,13 @@ int CDbxMDBX::InitCrypt() }
key.iov_len = sizeof(DBKey_Crypto_IsEncrypted); key.iov_base = DBKey_Crypto_IsEncrypted;
-
- if (mdbx_get(txn, m_dbCrypto, &key, &value) == MDBX_SUCCESS)
- m_bEncrypted = *(const bool*)value.iov_base;
- else
- m_bEncrypted = false;
+ {
+ txn_ptr_ro txn(m_txn_ro);
+ if (mdbx_get(txn, m_dbCrypto, &key, &value) == MDBX_SUCCESS)
+ m_bEncrypted = *(const bool *)value.iov_base;
+ else
+ m_bEncrypted = false;
+ }
InitDialogs();
return 0;
|