From 2bac0330a0e427bbc4f6773c4023f4bd9d667835 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 30 Dec 2013 08:39:34 +0000 Subject: fix for old mmap keys, then corrupted by mmap_sa git-svn-id: http://svn.miranda-ng.org/main/trunk@7420 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Db3x_mmap/src/dbcrypt.cpp | 13 ++++++++++++- plugins/Db3x_mmap/src/dbheaders.cpp | 2 +- plugins/Db3x_mmap/src/dbintf.h | 4 +++- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/plugins/Db3x_mmap/src/dbcrypt.cpp b/plugins/Db3x_mmap/src/dbcrypt.cpp index 7b384cedfe..f181f53cd2 100644 --- a/plugins/Db3x_mmap/src/dbcrypt.cpp +++ b/plugins/Db3x_mmap/src/dbcrypt.cpp @@ -162,9 +162,15 @@ LBL_SetNewKey: goto LBL_SetNewKey; if (!m_crypto->setKey(dbv.pbVal, iKeyLength)) - if (!EnterPassword(dbv.pbVal, iKeyLength)) // password protected? + if (!EnterPassword(dbv.pbVal, iKeyLength)) { // password protected? + if (m_dbHeader.version == DB_THIS_VERSION) return 4; + // one of the early used version of mmap was replaced then by mmap_sa + // simply remove old badly generated key + goto LBL_SetNewKey; + } + FreeVariant(&dbv); } @@ -178,6 +184,11 @@ LBL_SetNewKey: DBWrite(0, &dbSignatureU, sizeof(dbSignatureU)); } + if (m_dbHeader.version == DB_OLD_VERSION) { + m_dbHeader.version = DB_THIS_VERSION; + DBWrite(sizeof(dbSignatureU), &m_dbHeader.version, sizeof(m_dbHeader.version)); + } + InitDialogs(); return 0; } diff --git a/plugins/Db3x_mmap/src/dbheaders.cpp b/plugins/Db3x_mmap/src/dbheaders.cpp index e7f83996a5..899dcdedc7 100644 --- a/plugins/Db3x_mmap/src/dbheaders.cpp +++ b/plugins/Db3x_mmap/src/dbheaders.cpp @@ -60,7 +60,7 @@ int CDb3Base::CheckDbHeaders() memcmp(m_dbHeader.signature, &dbSignatureSA, sizeof(m_dbHeader.signature))) return EGROKPRF_UNKHEADER; - if (m_dbHeader.version != DB_THIS_VERSION) + if (m_dbHeader.version != DB_THIS_VERSION && m_dbHeader.version != DB_OLD_VERSION) return EGROKPRF_VERNEWER; if (m_dbHeader.ofsUser == 0) diff --git a/plugins/Db3x_mmap/src/dbintf.h b/plugins/Db3x_mmap/src/dbintf.h index 0724f14cd5..0ac1db9353 100644 --- a/plugins/Db3x_mmap/src/dbintf.h +++ b/plugins/Db3x_mmap/src/dbintf.h @@ -44,7 +44,9 @@ DBHeader \--> ... */ -#define DB_THIS_VERSION 0x00000700u +#define DB_OLD_VERSION 0x00000700u +#define DB_THIS_VERSION 0x00000701u + #define DB_SETTINGS_RESIZE_GRANULARITY 128 #define WSOFS_END 0xFFFFFFFF -- cgit v1.2.3