mirror of
https://github.com/haiwen/seafile.git
synced 2025-01-09 04:17:30 +08:00
correctly check RAND_bytes error code
This commit is contained in:
parent
fc8d8b790e
commit
0aae00f0a9
@ -79,7 +79,7 @@ seafile_generate_random_key (const char *passwd, char *random_key)
|
||||
int outlen;
|
||||
unsigned char key[32], iv[16];
|
||||
|
||||
if (!RAND_bytes (secret_key, sizeof(secret_key))) {
|
||||
if (RAND_bytes (secret_key, sizeof(secret_key)) != 1) {
|
||||
seaf_warning ("Failed to generate secret key for repo encryption "
|
||||
"with RAND_bytes(), use RAND_pseudo_bytes().\n");
|
||||
RAND_pseudo_bytes (secret_key, sizeof(secret_key));
|
||||
|
@ -1231,7 +1231,7 @@ generate_session_key (BlockTxInfo *info, const char *peer_id)
|
||||
char *sk_base64, *sk_enc_base64;
|
||||
gsize enc_key_len;
|
||||
|
||||
if (!RAND_bytes (info->session_key, sizeof(info->session_key))) {
|
||||
if (RAND_bytes (info->session_key, sizeof(info->session_key)) != 1) {
|
||||
seaf_warning ("Failed to generate random session key with RAND_bytes(), "
|
||||
"switch to RAND_pseudo_bytes().\n");
|
||||
RAND_pseudo_bytes (info->session_key, sizeof(info->session_key));
|
||||
|
Loading…
Reference in New Issue
Block a user