summaryrefslogtreecommitdiff
path: root/plugins/Dbx_mdb/src/dbcrypt.cpp
diff options
context:
space:
mode:
authorMikalaiR <nikolay.romanovich@narod.ru>2016-03-22 15:11:48 +0000
committerMikalaiR <nikolay.romanovich@narod.ru>2016-03-22 15:11:48 +0000
commitd2c91898a866006be4bd56b00e5cd36112ca5e06 (patch)
tree614d9d17e05739433fdbe68d247c5f199cdba019 /plugins/Dbx_mdb/src/dbcrypt.cpp
parentce1bf81b56ff2dad89b1f783d6377b20eebea0a4 (diff)
dbx_lmdb: some fixes
git-svn-id: http://svn.miranda-ng.org/main/trunk@16522 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Dbx_mdb/src/dbcrypt.cpp')
-rw-r--r--plugins/Dbx_mdb/src/dbcrypt.cpp55
1 files changed, 20 insertions, 35 deletions
diff --git a/plugins/Dbx_mdb/src/dbcrypt.cpp b/plugins/Dbx_mdb/src/dbcrypt.cpp
index 3e23dfdfa6..76e92cbea8 100644
--- a/plugins/Dbx_mdb/src/dbcrypt.cpp
+++ b/plugins/Dbx_mdb/src/dbcrypt.cpp
@@ -90,35 +90,24 @@ int CDbxMdb::InitCrypt()
return 3;
key.mv_size = sizeof(DBKEY_KEY); key.mv_data = DBKEY_KEY;
- if (mdb_get(txn, m_dbCrypto, &key, &value) == MDB_SUCCESS)
+ if (mdb_get(txn, m_dbCrypto, &key, &value) == MDB_SUCCESS && (value.mv_size == m_crypto->getKeyLength()))
{
- if (value.mv_size != m_crypto->getKeyLength())
- {
- if (!m_crypto->generateKey())
- return 6;
- StoreKey();
- }
- else
+ if (!m_crypto->setKey((const BYTE*)value.mv_data, value.mv_size))
{
- if (!m_crypto->setKey((const BYTE*)value.mv_data, value.mv_size))
+ DlgChangePassParam param = { this };
+ CEnterPasswordDialog dlg(&param);
+ while (true)
{
- DlgChangePassParam param = { this };
- CEnterPasswordDialog dlg(&param);
- while (true)
+ if (-128 != dlg.DoModal())
+ return 4;
+ m_crypto->setPassword(pass_ptrA(mir_utf8encodeT(param.newPass)));
+ if (m_crypto->setKey((const BYTE*)value.mv_data, value.mv_size))
{
- if (-128 != dlg.DoModal())
- return 4;
-
- m_crypto->setPassword(pass_ptrA(mir_utf8encodeT(param.newPass)));
- if (m_crypto->setKey((const BYTE*)value.mv_data, value.mv_size))
- {
- m_bUsesPassword = true;
- SecureZeroMemory(&param, sizeof(param));
- break;
- }
-
- param.wrongPass++;
+ m_bUsesPassword = true;
+ SecureZeroMemory(&param, sizeof(param));
+ break;
}
+ param.wrongPass++;
}
}
}
@@ -181,24 +170,21 @@ int CDbxMdb::EnableEncryption(bool bEncrypted)
mir_cslock lck(m_csDbAccess);
-/* { WTF ?!
+#ifdef DEBUG
+ {
txn_ptr_ro txn(m_txn);
std::vector<MEVENT> lstEvents;
{
cursor_ptr_ro cursor(m_curEvents);
MDB_val key, data;
- if (mdb_cursor_get(cursor, &key, &data, MDB_FIRST) == MDB_SUCCESS)
+ while (mdb_cursor_get(cursor, &key, &data, MDB_NEXT) == MDB_SUCCESS)
{
- do
- {
- const MEVENT hDbEvent = *(MEVENT*)key.mv_data;
- lstEvents.push_back(hDbEvent);
- } while (mdb_cursor_get(cursor, &key, &data, MDB_NEXT) == MDB_SUCCESS);
+ const MEVENT hDbEvent = *(const MEVENT*)key.mv_data;
+ lstEvents.push_back(hDbEvent);
}
}
- for (auto it = lstEvents.begin(); it != lstEvents.end(); ++it)
+ for (MEVENT &hDbEvent : lstEvents)
{
- MEVENT &hDbEvent = *it;
MDB_val key = { sizeof(MEVENT), &hDbEvent }, data;
mdb_get(txn, m_dbEvents, &key, &data);
@@ -244,8 +230,7 @@ int CDbxMdb::EnableEncryption(bool bEncrypted)
}
}
}
-*/
-
+#endif
for (;; Remap())
{