Skip to content

Commit 286a999

Browse files
committed
Prepare release of version 1.3.1
Prevent rekeying in WAL journal mode (could cause database corruption) Add some error messages (key, rekey, pragma handling)
1 parent 0d627f7 commit 286a999

File tree

5 files changed

+30
-5
lines changed

5 files changed

+30
-5
lines changed

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 <[email protected]>
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.0], [[email protected]])
7+
AC_INIT([sqlite3mc], [1.3.1], [[email protected]])
88

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

readme.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ The code was mainly developed under Windows, but was tested under Linux as well.
1212

1313
## Version history
1414

15+
* 1.3.1 - *April 2021*
16+
- Prevent rekey in WAL journal mode
17+
- Fix issue in user authentication extension that prevented VACUUMing or rekeying
1518
* 1.3.0 - *April 2021*
1619
- Based on SQLite version 3.35.5
1720
- Fix issue #37: Allow concurrent access from legacy applications by establishing WAL journal mode compatibility

src/cipher_config.c

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

@@ -809,6 +809,17 @@ sqlite3mcFileControlPragma(sqlite3* db, const char* zDbName, int op, void* pArg)
809809
{
810810
((char**)pArg)[0] = sqlite3_mprintf("ok");
811811
}
812+
else
813+
{
814+
if (db->pErr)
815+
{
816+
const char* z = sqlite3_value_text(db->pErr);
817+
if (z && sqlite3Strlen30(z) > 0)
818+
{
819+
((char**)pArg)[0] = sqlite3_mprintf(z);
820+
}
821+
}
822+
}
812823
}
813824
else
814825
{

src/codecext.c

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

@@ -346,6 +346,7 @@ sqlite3_key_v2(sqlite3* db, const char* zDbName, const void* zKey, int nKey)
346346
else
347347
{
348348
rc = SQLITE_ERROR;
349+
sqlite3ErrorWithMsg(db, rc, "Key failed. Database '%s' not found.", zDbName);
349350
}
350351
}
351352
return rc;
@@ -372,6 +373,7 @@ sqlite3_rekey_v2(sqlite3* db, const char* zDbName, const void* zKey, int nKey)
372373
dbIndex = (zDbName) ? sqlite3FindDbName(db, zDbName) : 0;
373374
if (dbIndex < 0)
374375
{
376+
sqlite3ErrorWithMsg(db, rc, "Rekey failed. Database '%s' not found.", zDbName);
375377
return rc;
376378
}
377379
pBt = db->aDb[dbIndex].pBt;
@@ -384,6 +386,12 @@ sqlite3_rekey_v2(sqlite3* db, const char* zDbName, const void* zKey, int nKey)
384386
pPager = sqlite3BtreePager(pBt);
385387
codec = sqlite3mcGetCodec(db, zDbName);
386388

389+
if (pagerUseWal(pPager))
390+
{
391+
sqlite3ErrorWithMsg(db, rc, "Rekey is not supported in WAL journal mode.");
392+
return rc;
393+
}
394+
387395
if ((zKey == NULL || nKey == 0) && (codec == NULL || !sqlite3mcIsEncrypted(codec)))
388396
{
389397
/* Database not encrypted and key not specified, therefore do nothing */
@@ -431,6 +439,7 @@ sqlite3_rekey_v2(sqlite3* db, const char* zDbName, const void* zKey, int nKey)
431439
{
432440
/* Pagesize cannot be changed for an encrypted database */
433441
rc = SQLITE_ERROR;
442+
sqlite3ErrorWithMsg(db, rc, "Rekey failed. Pagesize cannot be changed for an encrypted database.");
434443
goto leave_rekey;
435444
}
436445
}
@@ -479,12 +488,14 @@ sqlite3_rekey_v2(sqlite3* db, const char* zDbName, const void* zKey, int nKey)
479488
{
480489
/* Pagesize cannot be changed for an encrypted database */
481490
rc = SQLITE_ERROR;
491+
sqlite3ErrorWithMsg(db, rc, "Rekey failed. Pagesize cannot be changed for an encrypted database.");
482492
goto leave_rekey;
483493
}
484494
}
485495
else
486496
{
487497
/* Setup of write cipher failed */
498+
sqlite3ErrorWithMsg(db, rc, "Rekey failed. Setup of write cipher failed.");
488499
goto leave_rekey;
489500
}
490501
}

src/sqlite3mc_version.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414

1515
#define SQLITE3MC_VERSION_MAJOR 1
1616
#define SQLITE3MC_VERSION_MINOR 3
17-
#define SQLITE3MC_VERSION_RELEASE 0
17+
#define SQLITE3MC_VERSION_RELEASE 1
1818
#define SQLITE3MC_VERSION_SUBRELEASE 0
19-
#define SQLITE3MC_VERSION_STRING "SQLite3 Multiple Ciphers 1.3.0"
19+
#define SQLITE3MC_VERSION_STRING "SQLite3 Multiple Ciphers 1.3.1"
2020

2121
#endif /* SQLITE3MC_VERSION_H_ */

0 commit comments

Comments
 (0)