Skip to content

Commit

Permalink
RAND_bytes_ex: fix return check
Browse files Browse the repository at this point in the history
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from #17032)
  • Loading branch information
PeiweiHu authored and paulidale committed Nov 16, 2021
1 parent e48fe79 commit c9007bd
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion ssl/record/tls_pad.c
Expand Up @@ -251,7 +251,7 @@ static int ssl3_cbc_copy_mac(size_t *reclen,
}

/* Create the random MAC we will emit if padding is bad */
if (!RAND_bytes_ex(libctx, randmac, mac_size, 0))
if (RAND_bytes_ex(libctx, randmac, mac_size, 0) <= 0)
return 0;

if (!ossl_assert(mac != NULL && alloced != NULL))
Expand Down
2 changes: 1 addition & 1 deletion test/provfetchtest.c
Expand Up @@ -213,7 +213,7 @@ static int dummy_provider_init(const OSSL_CORE_HANDLE *handle,
* Do some work using the child libctx, to make sure this is possible from
* inside the init function.
*/
if (!RAND_bytes_ex(libctx, buf, sizeof(buf), 0))
if (RAND_bytes_ex(libctx, buf, sizeof(buf), 0) <= 0)
return 0;

return 1;
Expand Down
2 changes: 1 addition & 1 deletion test/sslapitest.c
Expand Up @@ -1337,7 +1337,7 @@ static int execute_test_ktls_sendfile(int tls_version, const char *cipher)
goto end;
}

if (!TEST_true(RAND_bytes_ex(libctx, buf, SENDFILE_SZ, 0)))
if (!TEST_int_gt(RAND_bytes_ex(libctx, buf, SENDFILE_SZ, 0), 0))
goto end;

out = BIO_new_file(tmpfilename, "wb");
Expand Down
2 changes: 1 addition & 1 deletion test/tls-provider.c
Expand Up @@ -813,7 +813,7 @@ unsigned int randomize_tls_group_id(OSSL_LIB_CTX *libctx)
int i;

retry:
if (!RAND_bytes_ex(libctx, (unsigned char *)&group_id, sizeof(group_id), 0))
if (RAND_bytes_ex(libctx, (unsigned char *)&group_id, sizeof(group_id), 0) <= 0)
return 0;
/*
* Ensure group_id is within the IANA Reserved for private use range
Expand Down

0 comments on commit c9007bd

Please sign in to comment.