summaryrefslogtreecommitdiff
path: root/plugins/Db3x_mmap
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2013-12-05 18:27:53 +0000
committerGeorge Hazan <george.hazan@gmail.com>2013-12-05 18:27:53 +0000
commita4043c72c431d7654b3756d3b5c897751cb8f4f6 (patch)
tree9f6715f9ec574bf6eeff4360c57ec66bd7da5cec /plugins/Db3x_mmap
parent369e1612ac567185ada1f899c97fde57b6e3c47c (diff)
special signature added for the encrypted database
git-svn-id: http://svn.miranda-ng.org/main/trunk@7054 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Db3x_mmap')
-rw-r--r--plugins/Db3x_mmap/src/commonheaders.h2
-rw-r--r--plugins/Db3x_mmap/src/dbcrypt.cpp8
-rw-r--r--plugins/Db3x_mmap/src/dbheaders.cpp4
-rw-r--r--plugins/Db3x_mmap/src/dbintf.cpp3
-rw-r--r--plugins/Db3x_mmap/src/dbtool/initialchecks.cpp2
-rw-r--r--plugins/Db3x_mmap/src/init.cpp2
6 files changed, 13 insertions, 8 deletions
diff --git a/plugins/Db3x_mmap/src/commonheaders.h b/plugins/Db3x_mmap/src/commonheaders.h
index f8978defe4..9cbdf6dc0e 100644
--- a/plugins/Db3x_mmap/src/commonheaders.h
+++ b/plugins/Db3x_mmap/src/commonheaders.h
@@ -45,7 +45,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
extern HINSTANCE g_hInst;
extern LIST<CDb3Mmap> g_Dbs;
-extern DBSignature dbSignature, dbSignatureIM, dbSignatureSA;
+extern DBSignature dbSignatureU, dbSignatureE, dbSignatureIM, dbSignatureSA;
#ifdef __GNUC__
#define mir_i64(x) (x##LL)
diff --git a/plugins/Db3x_mmap/src/dbcrypt.cpp b/plugins/Db3x_mmap/src/dbcrypt.cpp
index 4cd24f2ee9..179698fb1f 100644
--- a/plugins/Db3x_mmap/src/dbcrypt.cpp
+++ b/plugins/Db3x_mmap/src/dbcrypt.cpp
@@ -167,12 +167,14 @@ LBL_SetNewKey:
FreeVariant(&dbv);
}
- if (memcmp(&m_dbHeader.signature, &dbSignature, sizeof(m_dbHeader.signature))) {
+ if (memcmp(&m_dbHeader.signature, &dbSignatureU, sizeof(m_dbHeader.signature)) &&
+ memcmp(&m_dbHeader.signature, &dbSignatureE, sizeof(m_dbHeader.signature)))
+ {
EnumModuleNames(sttModuleEnum, this);
// upgrade signature
- memcpy(&m_dbHeader.signature, &dbSignature, sizeof(dbSignature));
- DBWrite(0, &dbSignature, sizeof(dbSignature));
+ memcpy(&m_dbHeader.signature, &dbSignatureU, sizeof(dbSignatureU));
+ DBWrite(0, &dbSignatureU, sizeof(dbSignatureU));
}
InitDialogs();
diff --git a/plugins/Db3x_mmap/src/dbheaders.cpp b/plugins/Db3x_mmap/src/dbheaders.cpp
index 5fe77eb0ba..e7f83996a5 100644
--- a/plugins/Db3x_mmap/src/dbheaders.cpp
+++ b/plugins/Db3x_mmap/src/dbheaders.cpp
@@ -54,7 +54,8 @@ int CDb3Base::CreateDbHeaders(const DBSignature& _sign)
int CDb3Base::CheckDbHeaders()
{
- if (memcmp(m_dbHeader.signature, &dbSignature, sizeof(m_dbHeader.signature)) &&
+ if (memcmp(m_dbHeader.signature, &dbSignatureU, sizeof(m_dbHeader.signature)) &&
+ memcmp(m_dbHeader.signature, &dbSignatureE, sizeof(m_dbHeader.signature)) &&
memcmp(m_dbHeader.signature, &dbSignatureIM, sizeof(m_dbHeader.signature)) &&
memcmp(m_dbHeader.signature, &dbSignatureSA, sizeof(m_dbHeader.signature)))
return EGROKPRF_UNKHEADER;
@@ -65,5 +66,6 @@ int CDb3Base::CheckDbHeaders()
if (m_dbHeader.ofsUser == 0)
return EGROKPRF_DAMAGED;
+ m_bEncrypted = 0 == memcmp(m_dbHeader.signature, &dbSignatureE, sizeof(m_dbHeader.signature));
return 0;
}
diff --git a/plugins/Db3x_mmap/src/dbintf.cpp b/plugins/Db3x_mmap/src/dbintf.cpp
index 398bd0c618..5ca465d5ee 100644
--- a/plugins/Db3x_mmap/src/dbintf.cpp
+++ b/plugins/Db3x_mmap/src/dbintf.cpp
@@ -23,7 +23,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "commonheaders.h"
-DBSignature dbSignature = { "Miranda NG DBu", 0x1A };
+DBSignature dbSignatureU = { "Miranda NG DBu", 0x1A }; // unencrypted database
+DBSignature dbSignatureE = { "Miranda NG DBe", 0x1A }; // encrypted database
DBSignature dbSignatureIM = { "Miranda ICQ DB", 0x1A };
DBSignature dbSignatureSA = { "Miranda ICQ SA", 0x1A };
diff --git a/plugins/Db3x_mmap/src/dbtool/initialchecks.cpp b/plugins/Db3x_mmap/src/dbtool/initialchecks.cpp
index 2b199312cf..4f65192169 100644
--- a/plugins/Db3x_mmap/src/dbtool/initialchecks.cpp
+++ b/plugins/Db3x_mmap/src/dbtool/initialchecks.cpp
@@ -20,7 +20,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
int CDb3Base::WorkInitialCheckHeaders()
{
- if (memcmp(m_dbHeader.signature, &dbSignature, sizeof(m_dbHeader.signature)) &&
+ if (memcmp(m_dbHeader.signature, &dbSignatureU, sizeof(m_dbHeader.signature)) &&
memcmp(m_dbHeader.signature, &dbSignatureIM, sizeof(m_dbHeader.signature)))
{
cb->pfnAddLogMessage(STATUS_FATAL,TranslateT("Database signature is corrupted, automatic repair is impossible"));
diff --git a/plugins/Db3x_mmap/src/init.cpp b/plugins/Db3x_mmap/src/init.cpp
index c596b72755..315fdc4d65 100644
--- a/plugins/Db3x_mmap/src/init.cpp
+++ b/plugins/Db3x_mmap/src/init.cpp
@@ -53,7 +53,7 @@ static int makeDatabase(const TCHAR *profile)
if (db->Create() != ERROR_SUCCESS)
return EMKPRF_CREATEFAILED;
- return db->CreateDbHeaders(dbSignature);
+ return db->CreateDbHeaders(dbSignatureU);
}
// returns 0 if the given profile has a valid header