From 979f690669a50c203ee1c9f9442a13cb53ecc61c Mon Sep 17 00:00:00 2001 From: Stephen Lombardo Date: Tue, 11 Jun 2013 13:11:41 -0400 Subject: [PATCH] check return code on RAND_bytes(); --- src/crypto_openssl.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/crypto_openssl.c b/src/crypto_openssl.c index 84665ced..44d887b8 100644 --- a/src/crypto_openssl.c +++ b/src/crypto_openssl.c @@ -66,10 +66,9 @@ static const char* sqlcipher_openssl_get_provider_name(void *ctx) { return "openssl"; } -/* generate a defined number of pseudorandom bytes */ +/* generate a defined number of random bytes */ static int sqlcipher_openssl_random (void *ctx, void *buffer, int length) { - RAND_bytes((unsigned char *)buffer, length); - return SQLITE_OK; + return (RAND_bytes((unsigned char *)buffer, length) == 1) ? SQLITE_OK : SQLITE_ERROR; } static int sqlcipher_openssl_hmac(void *ctx, unsigned char *hmac_key, int key_sz, unsigned char *in, int in_sz, unsigned char *in2, int in2_sz, unsigned char *out) { -- 2.11.4.GIT