From c6bf239e2b4af7719a7b57b9060b008830490c80 Mon Sep 17 00:00:00 2001 From: Stephen Lombardo Date: Wed, 15 Nov 2023 10:06:09 -0500 Subject: [PATCH] cipher_integrity check will report expected page size if invalid --- src/crypto_impl.c | 2 +- test/sqlcipher-integrity.test | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/crypto_impl.c b/src/crypto_impl.c index 318c48b0..6e3ab2c3 100644 --- a/src/crypto_impl.c +++ b/src/crypto_impl.c @@ -1391,7 +1391,7 @@ int sqlcipher_codec_ctx_integrity_check(codec_ctx *ctx, Parse *pParse, char *col } if(file_sz % ctx->page_sz != 0) { - result = sqlite3_mprintf("page %d has an invalid size of %lld bytes", page, file_sz - ((file_sz / ctx->page_sz) * ctx->page_sz)); + result = sqlite3_mprintf("page %d has an invalid size of %lld bytes (expected %d bytes)", page, file_sz - ((file_sz / ctx->page_sz) * ctx->page_sz), ctx->page_sz); sqlite3VdbeAddOp4(v, OP_String8, 0, 1, 0, result, P4_DYNAMIC); sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 1); } diff --git a/test/sqlcipher-integrity.test b/test/sqlcipher-integrity.test index 5e13eff9..fa094989 100644 --- a/test/sqlcipher-integrity.test +++ b/test/sqlcipher-integrity.test @@ -310,7 +310,7 @@ do_test version-4-integrity-check-invalid-last-page { PRAGMA key = 'testkey'; PRAGMA cipher_integrity_check; } -} {ok {page 240 has an invalid size of 2 bytes}} +} {ok {page 240 has an invalid size of 2 bytes (expected 4096 bytes)}} db close file delete -force test.db -- 2.11.4.GIT