@@ -191,6 +191,7 @@ int sqlcipher_codec_pragma(sqlite3* db, int iDb, Parse *pParse, const char *zLef
191191 char * migrate_status = sqlite3_mprintf ("%d" , status );
192192 codec_vdbe_return_string (pParse , "cipher_migrate" , migrate_status , P4_DYNAMIC );
193193 if (status != SQLITE_OK ) {
194+ CODEC_TRACE ("sqlcipher_codec_pragma: error occurred during cipher_migrate: %d\n" , status );
194195 sqlcipher_codec_ctx_set_error (ctx , status );
195196 }
196197 }
@@ -723,6 +724,7 @@ static void* sqlite3Codec(void *iCtx, void *data, Pgno pgno, int mode) {
723724
724725 /* call to derive keys if not present yet */
725726 if ((rc = sqlcipher_codec_key_derive (ctx )) != SQLITE_OK ) {
727+ CODEC_TRACE ("sqlite3Codec: error occurred during key derivation: %d\n" , rc );
726728 sqlcipher_codec_ctx_set_error (ctx , rc );
727729 return NULL ;
728730 }
@@ -731,6 +733,7 @@ static void* sqlite3Codec(void *iCtx, void *data, Pgno pgno, int mode) {
731733 PRAGMA. We can't set the error state on the pager at that point because the pager
732734 may not be open yet. However, this is a fatal error state, so abort the codec */
733735 if (plaintext_header_sz < 0 ) {
736+ CODEC_TRACE ("sqlite3Codec: error invalid plaintext_header_sz: %d\n" , plaintext_header_sz );
734737 sqlcipher_codec_ctx_set_error (ctx , SQLITE_ERROR );
735738 return NULL ;
736739 }
@@ -755,6 +758,7 @@ static void* sqlite3Codec(void *iCtx, void *data, Pgno pgno, int mode) {
755758 if (rc != SQLITE_OK ) {
756759 /* failure to decrypt a page is considered a permanent error and will render the pager unusable
757760 in order to prevent inconsistent data being loaded into page cache */
761+ CODEC_TRACE ("sqlite3Codec: error decrypting page data: %d\n" , rc );
758762 sqlcipher_memset ((unsigned char * ) buffer + offset , 0 , page_sz - offset );
759763 sqlcipher_codec_ctx_set_error (ctx , rc );
760764 }
@@ -770,6 +774,7 @@ static void* sqlite3Codec(void *iCtx, void *data, Pgno pgno, int mode) {
770774 void * kdf_salt = NULL ;
771775 /* retrieve the kdf salt */
772776 if ((rc = sqlcipher_codec_ctx_get_kdf_salt (ctx , & kdf_salt )) != SQLITE_OK ) {
777+ CODEC_TRACE ("sqlite3Codec: error retrieving salt: %d\n" , rc );
773778 sqlcipher_codec_ctx_set_error (ctx , rc );
774779 return NULL ;
775780 }
@@ -785,6 +790,7 @@ static void* sqlite3Codec(void *iCtx, void *data, Pgno pgno, int mode) {
785790 if (rc != SQLITE_OK ) {
786791 /* failure to encrypt a page is considered a permanent error and will render the pager unusable
787792 in order to prevent corrupted pages from being written to the main databased when using WAL */
793+ CODEC_TRACE ("sqlite3Codec: error encrypting page data: %d\n" , rc );
788794 sqlcipher_memset ((unsigned char * )buffer + offset , 0 , page_sz - offset );
789795 sqlcipher_codec_ctx_set_error (ctx , rc );
790796 return NULL ;
@@ -793,6 +799,7 @@ static void* sqlite3Codec(void *iCtx, void *data, Pgno pgno, int mode) {
793799 break ;
794800
795801 default :
802+ CODEC_TRACE ("sqlite3Codec: error unsupported codec mode %d\n" , mode );
796803 sqlcipher_codec_ctx_set_error (ctx , SQLITE_ERROR ); /* unsupported mode, set error */
797804 return pData ;
798805 break ;
0 commit comments