aboutsummaryrefslogtreecommitdiff
path: root/lib/vtls
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2016-12-23 15:29:01 +0100
committerDaniel Stenberg <daniel@haxx.se>2016-12-23 15:29:01 +0100
commit00c817068ed9e73974b3fedf6b9d7cb085db69f4 (patch)
treebca719b16e7ae20d0d3136d899fefe86303a074f /lib/vtls
parentc7834ecd45194dbca9762ad8fc06072b77481a29 (diff)
openssl-random: check return code when asking for random
and fail appropriately if it returns error
Diffstat (limited to 'lib/vtls')
-rw-r--r--lib/vtls/openssl.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/vtls/openssl.c b/lib/vtls/openssl.c
index d92e71365..df8f11f34 100644
--- a/lib/vtls/openssl.c
+++ b/lib/vtls/openssl.c
@@ -3275,6 +3275,7 @@ size_t Curl_ossl_version(char *buffer, size_t size)
int Curl_ossl_random(struct Curl_easy *data, unsigned char *entropy,
size_t length)
{
+ int rc;
if(data) {
if(Curl_ossl_seed(data)) /* Initiate the seed if not already done */
return 1; /* couldn't seed for some reason */
@@ -3283,8 +3284,9 @@ int Curl_ossl_random(struct Curl_easy *data, unsigned char *entropy,
if(!rand_enough())
return 1;
}
- RAND_bytes(entropy, curlx_uztosi(length));
- return 0; /* 0 as in no problem */
+ /* RAND_bytes() returns 1 on success, 0 otherwise. */
+ rc = RAND_bytes(entropy, curlx_uztosi(length));
+ return rc^1;
}
void Curl_ossl_md5sum(unsigned char *tmp, /* input */