diff --git a/CHANGELOG.md b/CHANGELOG.md index 21ab158..758c432 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ All notable changes to this project will be documented in this file. - Cryptograpic provider interface cleanup - Rework of mutex allocation and management - Resolves miscellaneous build warnings +- Force error state at database pager level if SQLCipher initialization fails ## [4.2.0] - (May 2019 - [4.2.0 changes]) - Adds PRAGMA cipher_integrity_check to perform independent verification of page HMACs diff --git a/src/crypto.c b/src/crypto.c index 4a1d6cc..f66b4d9 100644 --- a/src/crypto.c +++ b/src/crypto.c @@ -767,6 +767,10 @@ int sqlite3CodecAttach(sqlite3* db, int nDb, const void *zKey, int nKey) { if(rc != SQLITE_OK) { /* initialization failed, do not attach potentially corrupted context */ CODEC_TRACE("sqlite3CodecAttach: context initialization failed with rc=%d\n", rc); + /* force an error at the pager level, such that even the upstream caller ignores the return code + the pager will be in an error state and will process no further operations */ + sqlite3pager_error(pPager, rc); + pDb->pBt->pBt->db->errCode = rc; CODEC_TRACE_MUTEX("sqlite3CodecAttach: leaving database mutex %p (early return on rc=%d)\n", db->mutex, rc); sqlite3_mutex_leave(db->mutex); CODEC_TRACE_MUTEX("sqlite3CodecAttach: left database mutex %p (early return on rc=%d)\n", db->mutex, rc);