Skip to content

Commit 979f690

Browse files
committed
check return code on RAND_bytes();
1 parent 1862c0d commit 979f690

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/crypto_openssl.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,9 @@ static const char* sqlcipher_openssl_get_provider_name(void *ctx) {
6666
return "openssl";
6767
}
6868

69-
/* generate a defined number of pseudorandom bytes */
69+
/* generate a defined number of random bytes */
7070
static int sqlcipher_openssl_random (void *ctx, void *buffer, int length) {
71-
RAND_bytes((unsigned char *)buffer, length);
72-
return SQLITE_OK;
71+
return (RAND_bytes((unsigned char *)buffer, length) == 1) ? SQLITE_OK : SQLITE_ERROR;
7372
}
7473

7574
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) {

0 commit comments

Comments
 (0)