diff options
author | George Hazan <george.hazan@gmail.com> | 2013-12-29 20:27:41 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2013-12-29 20:27:41 +0000 |
commit | 93b3fbbd45e45ec24c9d06ee529840cc3c2d4f29 (patch) | |
tree | 1b3d78cbe7c3c3bb71c174ce06d0082d191f16dd | |
parent | 7e0c7c426f9c8a453deef09c3d6679824af5f3d5 (diff) |
when mmap_sa opens a database, it must decrypt it, change signature to mmap and die
git-svn-id: http://svn.miranda-ng.org/main/trunk@7416 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r-- | plugins/Dbx_mmap_SA/src/dbintf_sa.cpp | 27 | ||||
-rw-r--r-- | src/modules/database/database.cpp | 2 |
2 files changed, 18 insertions, 11 deletions
diff --git a/plugins/Dbx_mmap_SA/src/dbintf_sa.cpp b/plugins/Dbx_mmap_SA/src/dbintf_sa.cpp index a06af08da7..8427c75b8b 100644 --- a/plugins/Dbx_mmap_SA/src/dbintf_sa.cpp +++ b/plugins/Dbx_mmap_SA/src/dbintf_sa.cpp @@ -48,10 +48,21 @@ int CDbxMmapSA::Load(bool bSkipInit) if (!p)
return 1;
- if (m_bEncoding && !CheckPassword(LOWORD(m_dbHeader.version), p + 1))
- return 1;
+ if (m_bEncoding) {
+ if (!CheckPassword(LOWORD(m_dbHeader.version), p + 1))
+ return 1;
+
+ // password validated ok? decrypt database
+ DecodeAll();
+ }
+
+ // write back mmap's signature not to open this profile again
+ memcpy(&m_dbHeader.signature, &dbSignatureU, sizeof(dbSignatureU));
+ DBWrite(0, &dbSignatureU, sizeof(dbSignatureU));
+ return 1;
- InitDialogs();
+ // no need to init that crap again
+ // InitDialogs();
}
return 0;
@@ -63,13 +74,9 @@ int CDbxMmapSA::CheckDbHeaders() m_bEncoding = true;
else if (memcmp(m_dbHeader.signature, &dbSignatureNonSecured, sizeof(m_dbHeader.signature)) == 0)
m_bEncoding = false;
- else {
- m_bEncoding = false;
- if (memcmp(m_dbHeader.signature, &dbSignatureIM, sizeof(m_dbHeader.signature)))
- return EGROKPRF_UNKHEADER;
- if (LOWORD(m_dbHeader.version) != 0x0700)
- return EGROKPRF_VERNEWER;
- }
+ else
+ return EGROKPRF_UNKHEADER;
+
if (m_dbHeader.ofsUser == 0)
return EGROKPRF_DAMAGED;
return 0;
diff --git a/src/modules/database/database.cpp b/src/modules/database/database.cpp index a66e814e30..ae2a0d8cd4 100644 --- a/src/modules/database/database.cpp +++ b/src/modules/database/database.cpp @@ -354,7 +354,7 @@ int tryOpenDatabase(const TCHAR *tszProfile) db_setCurrent(currDb = pDb);
return 0;
}
- return 1;
+ delete pDb;
}
else {
switch (err) {
|