Skip to content

Commit 5f9fc6f

Browse files
Check cipher_page_size input for valid values
1 parent 1c495b9 commit 5f9fc6f

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

src/crypto_impl.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -648,6 +648,10 @@ void sqlcipher_codec_get_keyspec(codec_ctx *ctx, void **zKey, int *nKey) {
648648
}
649649

650650
int sqlcipher_codec_ctx_set_pagesize(codec_ctx *ctx, int size) {
651+
if(!((size != 0) && ((size & (size - 1)) == 0)) || size < 512 || size > 65536) {
652+
CODEC_TRACE(("cipher_page_size not a power of 2 and between 512 and 65536 inclusive\n"));
653+
return SQLITE_ERROR;
654+
}
651655
/* attempt to free the existing page buffer */
652656
sqlcipher_free(ctx->buffer,ctx->page_sz);
653657
ctx->page_sz = size;

0 commit comments

Comments
 (0)