From 5f9fc6f45f71628828b19b23b4282607f827e176 Mon Sep 17 00:00:00 2001 From: Nick Parker Date: Wed, 1 Mar 2017 16:06:06 -0600 Subject: [PATCH] Check cipher_page_size input for valid values --- src/crypto_impl.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/crypto_impl.c b/src/crypto_impl.c index e43704df..7818e60b 100644 --- a/src/crypto_impl.c +++ b/src/crypto_impl.c @@ -648,6 +648,10 @@ void sqlcipher_codec_get_keyspec(codec_ctx *ctx, void **zKey, int *nKey) { } int sqlcipher_codec_ctx_set_pagesize(codec_ctx *ctx, int size) { + if(!((size != 0) && ((size & (size - 1)) == 0)) || size < 512 || size > 65536) { + CODEC_TRACE(("cipher_page_size not a power of 2 and between 512 and 65536 inclusive\n")); + return SQLITE_ERROR; + } /* attempt to free the existing page buffer */ sqlcipher_free(ctx->buffer,ctx->page_sz); ctx->page_sz = size; -- 2.11.4.GIT