Skip to content

Commit 5427460

Browse files
committed
Apply minor adjustments
- Allow empty passphrase for `PRAGMA key` - Allow to fully disable including of user authentication by defining `SQLITE_USER_AUTHENTICATION=0`
1 parent db45273 commit 5427460

File tree

6 files changed

+29
-10
lines changed

6 files changed

+29
-10
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.3], [[email protected]])
7+
AC_INIT([sqlite3mc], [1.3.4], [[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.4 - *July 2021* (pending)
16+
- Allow empty passphrase for `PRAGMA key`
17+
- Allow to fully disable including of user authentication by defining `SQLITE_USER_AUTHENTICATION=0`
1518
* 1.3.3 - *June 2021*
1619
- Based on SQLite version 3.36.0
1720
* 1.3.2 - *May 2021*

src/codecext.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,11 @@ sqlite3mcCodecAttach(sqlite3* db, int nDb, const char* zPath, const void* zKey,
243243
{
244244
/* Main database not encrypted, no key given for attached database */
245245
sqlite3mcCodecFree(codec);
246+
/* Remove codec for main database */
247+
if (nDb == 0 && nKey == 0)
248+
{
249+
sqlite3mcSetCodec(db, dbFileName, NULL);
250+
}
246251
}
247252
}
248253
else
@@ -322,7 +327,8 @@ sqlite3_key_v2(sqlite3* db, const char* zDbName, const void* zKey, int nKey)
322327
/* Key is zero-terminated string */
323328
nKey = sqlite3Strlen30((const char*) zKey);
324329
}
325-
if ((db != NULL) && (zKey != NULL) && (nKey > 0))
330+
/* Database handle db and key must be given, but key length 0 is allowed */
331+
if ((db != NULL) && (zKey != NULL) && (nKey >= 0))
326332
{
327333
int dbIndex;
328334
const char* dbFileName = sqlite3_db_filename(db, zDbName);

src/sqlite3mc.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,15 @@ void sqlite3mc_shutdown(void);
4545
/*
4646
** Enable the user authentication feature
4747
*/
48+
#if !SQLITE_USER_AUTHENTICATION
49+
/* Option not defined or explicitly disabled */
4850
#ifndef SQLITE_USER_AUTHENTICATION
51+
/* Option not defined, therefore enable by default */
4952
#define SQLITE_USER_AUTHENTICATION 1
53+
#else
54+
/* Option defined and disabled, therefore undefine option */
55+
#undef SQLITE_USER_AUTHENTICATION
56+
#endif
5057
#endif
5158

5259
#if defined(_WIN32) || defined(WIN32)

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 3
17+
#define SQLITE3MC_VERSION_RELEASE 4
1818
#define SQLITE3MC_VERSION_SUBRELEASE 0
19-
#define SQLITE3MC_VERSION_STRING "SQLite3 Multiple Ciphers 1.3.3"
19+
#define SQLITE3MC_VERSION_STRING "SQLite3 Multiple Ciphers 1.3.4"
2020

2121
#endif /* SQLITE3MC_VERSION_H_ */

src/sqlite3mc_vfs.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -244,18 +244,21 @@ SQLITE_PRIVATE void sqlite3mcSetCodec(sqlite3* db, const char* zFileName, Codec*
244244
sqlite3mc_file* pDbMain = mcFindDbMainFileName(&mcVfsGlobal, zFileName);
245245
if (pDbMain)
246246
{
247-
if (pDbMain->codec)
247+
Codec* prevCodec = pDbMain->codec;
248+
Codec* msgCodec = (codec) ? codec : prevCodec;
249+
if (msgCodec)
250+
{
251+
/* Reset error state of pager */
252+
mcReportCodecError(sqlite3mcGetBtShared(msgCodec), SQLITE_OK);
253+
}
254+
if (prevCodec)
248255
{
249256
/*
250257
** Free a codec that was already associated with this main database file handle
251258
*/
252-
sqlite3mcCodecFree(pDbMain->codec);
259+
sqlite3mcCodecFree(prevCodec);
253260
}
254261
pDbMain->codec = codec;
255-
if (codec)
256-
{
257-
mcReportCodecError(sqlite3mcGetBtShared(codec), SQLITE_OK);
258-
}
259262
}
260263
else
261264
{

0 commit comments

Comments
 (0)