Skip to content

Commit dff5b42

Browse files
committed
force return NULL pointer on CODEC error
1 parent e0df9c6 commit dff5b42

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

src/crypto.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -714,6 +714,7 @@ static void* sqlite3Codec(void *iCtx, void *data, Pgno pgno, int mode) {
714714
if(rc != SQLITE_OK) { /* clear results of failed cipher operation and set error */
715715
sqlcipher_memset((unsigned char*) buffer+offset, 0, page_sz-offset);
716716
sqlcipher_codec_ctx_set_error(ctx, rc);
717+
return NULL;
717718
}
718719
memcpy(pData, buffer, page_sz); /* copy buffer data back to pData and return */
719720
return pData;
@@ -739,6 +740,7 @@ static void* sqlite3Codec(void *iCtx, void *data, Pgno pgno, int mode) {
739740
if(rc != SQLITE_OK) { /* clear results of failed cipher operation and set error */
740741
sqlcipher_memset((unsigned char*)buffer+offset, 0, page_sz-offset);
741742
sqlcipher_codec_ctx_set_error(ctx, rc);
743+
return NULL;
742744
}
743745
return buffer; /* return persistent buffer data, pData remains intact */
744746
break;

test/sqlcipher-codecerror.text

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ do_test codec-error-journal-wal {
111111
execsql {
112112
PRAGMA cipher_fail_next_encrypt = 0;
113113
PRAGMA key = 'testkey';
114-
-- PRAGMA integrity_check;
114+
PRAGMA integrity_check;
115115
PRAGMA cipher_integrity_check;
116116
}
117117

0 commit comments

Comments
 (0)