Skip to content

Commit e9b5642

Browse files
committed
force the pager to an error state if initialization fails for sqlcipher#347
1 parent 14dd199 commit e9b5642

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

src/crypto.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -767,6 +767,10 @@ int sqlite3CodecAttach(sqlite3* db, int nDb, const void *zKey, int nKey) {
767767
if(rc != SQLITE_OK) {
768768
/* initialization failed, do not attach potentially corrupted context */
769769
CODEC_TRACE("sqlite3CodecAttach: context initialization failed with rc=%d\n", rc);
770+
/* force an error at the pager level, such that even the upstream caller ignores the return code
771+
the pager will be in an error state and will process no further operations */
772+
sqlite3pager_error(pPager, rc);
773+
pDb->pBt->pBt->db->errCode = rc;
770774
CODEC_TRACE_MUTEX("sqlite3CodecAttach: leaving database mutex %p (early return on rc=%d)\n", db->mutex, rc);
771775
sqlite3_mutex_leave(db->mutex);
772776
CODEC_TRACE_MUTEX("sqlite3CodecAttach: left database mutex %p (early return on rc=%d)\n", db->mutex, rc);

0 commit comments

Comments
 (0)