Skip to content

Commit 2ce0166

Browse files
committed
clarifying comments about codec error handling
1 parent 1876fe6 commit 2ce0166

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

src/crypto.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -747,7 +747,9 @@ static void* sqlite3Codec(void *iCtx, void *data, Pgno pgno, int mode) {
747747
rc = SQLITE_ERROR;
748748
}
749749
#endif
750-
if(rc != SQLITE_OK) { /* clear results of failed cipher operation and set error */
750+
if(rc != SQLITE_OK) {
751+
/* failure to decrypt a page is considered a permanent error and will render the pager unusable
752+
in order to prevent inconsistent data being loaded into page cache */
751753
sqlcipher_memset((unsigned char*) buffer+offset, 0, page_sz-offset);
752754
sqlcipher_codec_ctx_set_error(ctx, rc);
753755
}
@@ -774,7 +776,9 @@ static void* sqlite3Codec(void *iCtx, void *data, Pgno pgno, int mode) {
774776
rc = SQLITE_ERROR;
775777
}
776778
#endif
777-
if(rc != SQLITE_OK) { /* clear results of failed cipher operation and set error */
779+
if(rc != SQLITE_OK) {
780+
/* failure to encrypt a page is considered a permanent error and will render the pager unusable
781+
in order to prevent corrupted pages from being written to the main databased when using WAL */
778782
sqlcipher_memset((unsigned char*)buffer+offset, 0, page_sz-offset);
779783
sqlcipher_codec_ctx_set_error(ctx, rc);
780784
return NULL;

0 commit comments

Comments
 (0)