3939#include "sqlcipher_ext.h"
4040#endif
4141
42- #ifdef SQLCIPHER_TEST
43- static int cipher_test_flags = 0 ;
44- #endif
45-
46- /* Generate code to return a string value */
4742static void codec_vdbe_return_string (Parse * pParse , const char * zLabel , const char * value , int value_type ){
4843 Vdbe * v = sqlite3GetVdbe (pParse );
4944 sqlite3VdbeSetNumCols (v , 1 );
@@ -119,13 +114,13 @@ int sqlcipher_codec_pragma(sqlite3* db, int iDb, Parse *pParse, const char *zLef
119114 if ( sqlite3StrICmp (zLeft ,"cipher_test" )== 0 ){
120115 if ( zRight ) {
121116 if (sqlite3StrICmp (zRight , "fail_next_encrypt" )) {
122- cipher_test_flags ^= TEST_FAIL_NEXT_ENCRYPT ;
117+ sqlcipher_set_test_flags ( sqlcipher_get_test_flags () ^ TEST_FAIL_NEXT_ENCRYPT ) ;
123118 } else
124119 if (sqlite3StrICmp (zRight , "fail_next_decrypt" )) {
125- cipher_test_flags ^= TEST_FAIL_NEXT_DECRYPT ;
120+ sqlcipher_set_test_flags ( sqlcipher_get_test_flags () ^ TEST_FAIL_NEXT_DECRYPT ) ;
126121 }
127122 } else {
128- char * flags = sqlite3_mprintf ("%d" , cipher_test_flags );
123+ char * flags = sqlite3_mprintf ("%d" , sqlcipher_get_test_flags () );
129124 codec_vdbe_return_string (pParse , "cipher_test" , flags , P4_DYNAMIC );
130125 }
131126 }else
@@ -714,7 +709,7 @@ static void* sqlite3Codec(void *iCtx, void *data, Pgno pgno, int mode) {
714709
715710 rc = sqlcipher_page_cipher (ctx , cctx , pgno , CIPHER_DECRYPT , page_sz - offset , pData + offset , (unsigned char * )buffer + offset );
716711#ifdef SQLCIPHER_TEST
717- if ((cipher_test_flags & TEST_FAIL_NEXT_ENCRYPT ) > 0 ) rc = SQLITE_ERROR ;
712+ if ((sqlcipher_get_test_flags () & TEST_FAIL_NEXT_ENCRYPT ) > 0 ) rc = SQLITE_ERROR ;
718713#endif
719714 if (rc != SQLITE_OK ) { /* clear results of failed cipher operation and set error */
720715 sqlcipher_memset ((unsigned char * ) buffer + offset , 0 , page_sz - offset );
@@ -739,7 +734,7 @@ static void* sqlite3Codec(void *iCtx, void *data, Pgno pgno, int mode) {
739734 }
740735 rc = sqlcipher_page_cipher (ctx , cctx , pgno , CIPHER_ENCRYPT , page_sz - offset , pData + offset , (unsigned char * )buffer + offset );
741736#ifdef SQLCIPHER_TEST
742- if ((cipher_test_flags & TEST_FAIL_NEXT_DECRYPT ) > 0 ) rc = SQLITE_ERROR ;
737+ if ((sqlcipher_get_test_flags () & TEST_FAIL_NEXT_DECRYPT ) > 0 ) rc = SQLITE_ERROR ;
743738#endif
744739 if (rc != SQLITE_OK ) { /* clear results of failed cipher operation and set error */
745740 sqlcipher_memset ((unsigned char * )buffer + offset , 0 , page_sz - offset );
0 commit comments