force return NULL pointer on CODEC error

This commit is contained in:
Stephen Lombardo 2020-11-10 17:35:19 -05:00
parent e0df9c6aa5
commit dff5b42562
2 changed files with 3 additions and 1 deletions

View File

@ -714,6 +714,7 @@ static void* sqlite3Codec(void *iCtx, void *data, Pgno pgno, int mode) {
if(rc != SQLITE_OK) { /* clear results of failed cipher operation and set error */
sqlcipher_memset((unsigned char*) buffer+offset, 0, page_sz-offset);
sqlcipher_codec_ctx_set_error(ctx, rc);
return NULL;
}
memcpy(pData, buffer, page_sz); /* copy buffer data back to pData and return */
return pData;
@ -739,6 +740,7 @@ static void* sqlite3Codec(void *iCtx, void *data, Pgno pgno, int mode) {
if(rc != SQLITE_OK) { /* clear results of failed cipher operation and set error */
sqlcipher_memset((unsigned char*)buffer+offset, 0, page_sz-offset);
sqlcipher_codec_ctx_set_error(ctx, rc);
return NULL;
}
return buffer; /* return persistent buffer data, pData remains intact */
break;

View File

@ -111,7 +111,7 @@ do_test codec-error-journal-wal {
execsql {
PRAGMA cipher_fail_next_encrypt = 0;
PRAGMA key = 'testkey';
-- PRAGMA integrity_check;
PRAGMA integrity_check;
PRAGMA cipher_integrity_check;
}