Skip to content

Commit c2eab8c

Browse files
committed
Prepare release of version 1.3.2
Fix issues #39 and #40
1 parent b8e0cd7 commit c2eab8c

5 files changed

Lines changed: 38 additions & 10 deletions

File tree

configure.ac

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ dnl Copyright (C) 2019-2021 Ulrich Telle <ulrich@telle-online.de>
44
dnl
55
dnl This file is covered by the same licence as the entire SQLite3 Multiple Ciphers package.
66

7-
AC_INIT([sqlite3mc], [1.3.1], [ulrich@telle-online.de])
7+
AC_INIT([sqlite3mc], [1.3.2], [ulrich@telle-online.de])
88

99
dnl This is the version tested with, might work with earlier ones.
1010
AC_PREREQ([2.69])

readme.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,15 @@ In the course of time several developers had asked for a stand-alone version of
66

77
In late February 2020 work started on a new implementation of a SQLite encryption extension that will be able to support SQLite 3.32.0 and later. The new approach is based on [SQLite's VFS feature](https://www.sqlite.org/vfs.html). This approach has its pros and cons. On the one hand, the code is less closely coupled with SQLite itself; on the other hand, access to SQLite's internal data structures is more complex.
88

9-
This project is _Work In Progress_. As of March 2021, the code base is now rather stable, however, further major code modifications and/or reorganizations may still occur.
9+
This project is _Work In Progress_. As of May 2021, the code base is now rather stable, however, further major code modifications and/or reorganizations may still occur.
1010

1111
The code was mainly developed under Windows, but was tested under Linux as well. At the moment no major issues are known.
1212

1313
## Version history
1414

15+
* 1.3.2 - *May 2021*
16+
- Added configuration parameter `mc_legacy_wal` (issue #40)
17+
- Fix issue #39: Corrupted WAL journal due to referencing the wrong codec pointer
1518
* 1.3.1 - *April 2021*
1619
- Prevent rekey in WAL journal mode
1720
- Fix issue in user authentication extension that prevented VACUUMing or rekeying

src/cipher_common.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
** Purpose: Implementation of SQLite codecs
44
** Author: Ulrich Telle
55
** Created: 2020-02-02
6-
** Copyright: (c) 2006-2020 Ulrich Telle
6+
** Copyright: (c) 2006-2021 Ulrich Telle
77
** License: MIT
88
*/
99

@@ -23,9 +23,9 @@ static unsigned char padding[] =
2323

2424
static CipherParams commonParams[] =
2525
{
26-
{ "cipher", CODEC_TYPE, CODEC_TYPE, 1, CODEC_TYPE_MAX },
27-
{ "hmac_check", 1, 1, 0, 1 },
28-
{ "mc_legacy_wal", 0, 0, 0, 1 },
26+
{ "cipher", CODEC_TYPE, CODEC_TYPE, 1, CODEC_TYPE_MAX },
27+
{ "hmac_check", 1, 1, 0, 1 },
28+
{ "mc_legacy_wal", SQLITE3MC_LEGACY_WAL, SQLITE3MC_LEGACY_WAL, 0, 1 },
2929
CIPHER_PARAMS_SENTINEL
3030
};
3131

src/cipher_common.h

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
** Purpose: Header for the ciphers of SQLite3 Multiple Ciphers
44
** Author: Ulrich Telle
55
** Created: 2020-02-02
6-
** Copyright: (c) 2006-2020 Ulrich Telle
6+
** Copyright: (c) 2006-2021 Ulrich Telle
77
** License: MIT
88
*/
99

@@ -240,4 +240,31 @@ SQLITE_PRIVATE void sqlite3mcCodecGetKey(sqlite3* db, int nDb, void** zKey, int*
240240
#define SQLITE3MC_DEBUG_HEX(DESC,BUFFER,LEN)
241241
#endif
242242

243+
/*
244+
** If encryption was enabled and WAL journal mode was used,
245+
** SQLite3 Multiple Ciphers encrypted the WAL journal frames up to version 1.2.5
246+
** within the VFS implementation. As a consequence the WAL journal file was not
247+
** compatible with legacy encryption implementations (for example, System.Data.SQLite
248+
** or SQLCipher). Additionally, the implementation of the WAL journal encryption
249+
** was broken, because reading and writing of complete WAL frames was not handled
250+
** correctly. Usually, operating in WAL journal mode worked nevertheless, but after
251+
** crashes the WAL journal file could be corrupted leading to data loss.
252+
**
253+
** Version 1.3.0 introduced a new way to handle WAL journal encryption. The advantage
254+
** is that the WAL journal file is now compatible with legacy encryption implementations.
255+
** Unfortunately the new implementation is not compatible with that used up to version
256+
** 1.2.5. To be able to access WAL journals created by prior versions, the configuration
257+
** parameter 'mc_legacy_wal' was introduced. If the parameter is set to 1, then the
258+
** prior WAL journal encryption mode is used. The default of this parameter can be set
259+
** at compile time by setting the symbol SQLITE3MC_LEGACY_WAL accordingly, but the actual
260+
** value can also be set at runtime using the pragma or the URI parameter 'mc_legacy_wal'.
261+
**
262+
** In principle, operating generally in WAL legacy mode is possible, but it is strongly
263+
** recommended to use the WAL legacy mode only to recover WAL journals left behind by
264+
** prior versions without data loss.
265+
*/
266+
#ifndef SQLITE3MC_LEGACY_WAL
267+
#define SQLITE3MC_LEGACY_WAL 0
268+
#endif
269+
243270
#endif

src/sqlite3mc_vfs.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
** Purpose: Implementation of SQLite VFS for Multiple Ciphers
44
** Author: Ulrich Telle
55
** Created: 2020-02-28
6-
** Copyright: (c) 2020 Ulrich Telle
6+
** Copyright: (c) 2020-2021 Ulrich Telle
77
** License: MIT
88
*/
99

@@ -1046,7 +1046,6 @@ static int mcIoWrite(sqlite3_file* pFile, const void* buffer, int count, sqlite3
10461046
*/
10471047
}
10481048
#endif
1049-
#if 1
10501049
/*
10511050
** The page content is encrypted in memory in the WAL journal handler.
10521051
** This provides for compatibility with legacy applications using the
@@ -1056,7 +1055,6 @@ static int mcIoWrite(sqlite3_file* pFile, const void* buffer, int count, sqlite3
10561055
{
10571056
rc = mcWriteWal(pFile, buffer, count, offset);
10581057
}
1059-
#endif
10601058
else
10611059
{
10621060
rc = REALFILE(pFile)->pMethods->xWrite(REALFILE(pFile), buffer, count, offset);

0 commit comments

Comments
 (0)