From e9b56427d0692866e222dda686b9bf28a549883e Mon Sep 17 00:00:00 2001 From: Stephen Lombardo Date: Thu, 19 Dec 2019 12:12:13 -0500 Subject: [PATCH] force the pager to an error state if initialization fails for #347 --- src/crypto.c | 4 ++++ 1 file changed, 4 insertions(+) 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);