Skip to content

Commit

Permalink
Apply minor adjustments
Browse files Browse the repository at this point in the history
- Allow empty passphrase for `PRAGMA key`
- Allow to fully disable including of user authentication by defining `SQLITE_USER_AUTHENTICATION=0`
  • Loading branch information
utelle committed Jul 23, 2021
1 parent db45273 commit 5427460
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 10 deletions.
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ dnl Copyright (C) 2019-2021 Ulrich Telle <[email protected]>
dnl
dnl This file is covered by the same licence as the entire SQLite3 Multiple Ciphers package.

AC_INIT([sqlite3mc], [1.3.3], [[email protected]])
AC_INIT([sqlite3mc], [1.3.4], [[email protected]])

dnl This is the version tested with, might work with earlier ones.
AC_PREREQ([2.69])
Expand Down
3 changes: 3 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ The code was mainly developed under Windows, but was tested under Linux as well.

## Version history

* 1.3.4 - *July 2021* (pending)
- Allow empty passphrase for `PRAGMA key`
- Allow to fully disable including of user authentication by defining `SQLITE_USER_AUTHENTICATION=0`
* 1.3.3 - *June 2021*
- Based on SQLite version 3.36.0
* 1.3.2 - *May 2021*
Expand Down
8 changes: 7 additions & 1 deletion src/codecext.c
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,11 @@ sqlite3mcCodecAttach(sqlite3* db, int nDb, const char* zPath, const void* zKey,
{
/* Main database not encrypted, no key given for attached database */
sqlite3mcCodecFree(codec);
/* Remove codec for main database */
if (nDb == 0 && nKey == 0)
{
sqlite3mcSetCodec(db, dbFileName, NULL);
}
}
}
else
Expand Down Expand Up @@ -322,7 +327,8 @@ sqlite3_key_v2(sqlite3* db, const char* zDbName, const void* zKey, int nKey)
/* Key is zero-terminated string */
nKey = sqlite3Strlen30((const char*) zKey);
}
if ((db != NULL) && (zKey != NULL) && (nKey > 0))
/* Database handle db and key must be given, but key length 0 is allowed */
if ((db != NULL) && (zKey != NULL) && (nKey >= 0))
{
int dbIndex;
const char* dbFileName = sqlite3_db_filename(db, zDbName);
Expand Down
7 changes: 7 additions & 0 deletions src/sqlite3mc.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,15 @@ void sqlite3mc_shutdown(void);
/*
** Enable the user authentication feature
*/
#if !SQLITE_USER_AUTHENTICATION
/* Option not defined or explicitly disabled */
#ifndef SQLITE_USER_AUTHENTICATION
/* Option not defined, therefore enable by default */
#define SQLITE_USER_AUTHENTICATION 1
#else
/* Option defined and disabled, therefore undefine option */
#undef SQLITE_USER_AUTHENTICATION
#endif
#endif

#if defined(_WIN32) || defined(WIN32)
Expand Down
4 changes: 2 additions & 2 deletions src/sqlite3mc_version.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

#define SQLITE3MC_VERSION_MAJOR 1
#define SQLITE3MC_VERSION_MINOR 3
#define SQLITE3MC_VERSION_RELEASE 3
#define SQLITE3MC_VERSION_RELEASE 4
#define SQLITE3MC_VERSION_SUBRELEASE 0
#define SQLITE3MC_VERSION_STRING "SQLite3 Multiple Ciphers 1.3.3"
#define SQLITE3MC_VERSION_STRING "SQLite3 Multiple Ciphers 1.3.4"

#endif /* SQLITE3MC_VERSION_H_ */
15 changes: 9 additions & 6 deletions src/sqlite3mc_vfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -244,18 +244,21 @@ SQLITE_PRIVATE void sqlite3mcSetCodec(sqlite3* db, const char* zFileName, Codec*
sqlite3mc_file* pDbMain = mcFindDbMainFileName(&mcVfsGlobal, zFileName);
if (pDbMain)
{
if (pDbMain->codec)
Codec* prevCodec = pDbMain->codec;
Codec* msgCodec = (codec) ? codec : prevCodec;
if (msgCodec)
{
/* Reset error state of pager */
mcReportCodecError(sqlite3mcGetBtShared(msgCodec), SQLITE_OK);
}
if (prevCodec)
{
/*
** Free a codec that was already associated with this main database file handle
*/
sqlite3mcCodecFree(pDbMain->codec);
sqlite3mcCodecFree(prevCodec);
}
pDbMain->codec = codec;
if (codec)
{
mcReportCodecError(sqlite3mcGetBtShared(codec), SQLITE_OK);
}
}
else
{
Expand Down

0 comments on commit 5427460

Please sign in to comment.