Skip to content

Commit b6a1473

Browse files
committed
adjust short read detection for autovacuum scenarios
1 parent ab595a5 commit b6a1473

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/crypto_impl.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1130,12 +1130,12 @@ int sqlcipher_page_cipher(codec_ctx *ctx, int for_ctx, Pgno pgno, int mode, int
11301130

11311131
sqlcipher_log(SQLCIPHER_LOG_DEBUG, "sqlcipher_page_cipher: comparing hmac on in=%p out=%p hmac_sz=%d", hmac_in, hmac_out, ctx->hmac_sz);
11321132
if(sqlcipher_memcmp(hmac_in, hmac_out, ctx->hmac_sz) != 0) { /* the hmac check failed */
1133-
if(sqlcipher_ismemset(in, 0, page_sz) == 0) {
1133+
if(sqlite3BtreeGetAutoVacuum(ctx->pBt) != BTREE_AUTOVACUUM_NONE && sqlcipher_ismemset(in, 0, page_sz) == 0) {
11341134
/* first check if the entire contents of the page is zeros. If so, this page
11351135
resulted from a short read (i.e. sqlite attempted to pull a page after the end of the file. these
11361136
short read failures must be ignored for autovaccum mode to work so wipe the output buffer
11371137
and return SQLITE_OK to skip the decryption step. */
1138-
sqlcipher_log(SQLCIPHER_LOG_INFO, "sqlcipher_page_cipher: zeroed page (short read) for pgno %d, encryption but returning SQLITE_OK", pgno);
1138+
sqlcipher_log(SQLCIPHER_LOG_WARN, "sqlcipher_page_cipher: zeroed page (short read) for pgno %d, encryption but returning SQLITE_OK", pgno);
11391139
sqlcipher_memset(out, 0, page_sz);
11401140
return SQLITE_OK;
11411141
} else {

0 commit comments

Comments
 (0)