Commit 15e44197 authored by Noah Misch's avatar Noah Misch

Remove optimization for RAND_poll() failing.

The loop to generate seed data will exit on RAND_status(), so we don't
need to handle the case of RAND_poll() failing separately.  Failures
here are rare, so this a code cleanup, essentially.

Daniel Gustafsson, reviewed by David Steele and Michael Paquier.

Discussion: https://postgr.es/m/9B038FA5-23E8-40D0-B932-D515E1D8F66A@yesql.se
parent ce4939ff
...@@ -108,7 +108,11 @@ pg_strong_random(void *buf, size_t len) ...@@ -108,7 +108,11 @@ pg_strong_random(void *buf, size_t len)
/* /*
* Check that OpenSSL's CSPRNG has been sufficiently seeded, and if not * Check that OpenSSL's CSPRNG has been sufficiently seeded, and if not
* add more seed data using RAND_poll(). With some older versions of * add more seed data using RAND_poll(). With some older versions of
* OpenSSL, it may be necessary to call RAND_poll() a number of times. * OpenSSL, it may be necessary to call RAND_poll() a number of times. If
* RAND_poll() fails to generate seed data within the given amount of
* retries, subsequent RAND_bytes() calls will fail, but we allow that to
* happen to let pg_strong_random() callers handle that with appropriate
* error handling.
*/ */
#define NUM_RAND_POLL_RETRIES 8 #define NUM_RAND_POLL_RETRIES 8
...@@ -120,16 +124,7 @@ pg_strong_random(void *buf, size_t len) ...@@ -120,16 +124,7 @@ pg_strong_random(void *buf, size_t len)
break; break;
} }
if (RAND_poll() == 0) RAND_poll();
{
/*
* RAND_poll() failed to generate any seed data, which means that
* RAND_bytes() will probably fail. For now, just fall through
* and let that happen. XXX: maybe we could seed it some other
* way.
*/
break;
}
} }
if (RAND_bytes(buf, len) == 1) if (RAND_bytes(buf, len) == 1)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment