Skip to content

Commit 15e4419

Browse files
committed
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
1 parent ce4939f commit 15e4419

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

src/port/pg_strong_random.c

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,11 @@ pg_strong_random(void *buf, size_t len)
108108
/*
109109
* Check that OpenSSL's CSPRNG has been sufficiently seeded, and if not
110110
* add more seed data using RAND_poll(). With some older versions of
111-
* OpenSSL, it may be necessary to call RAND_poll() a number of times.
111+
* OpenSSL, it may be necessary to call RAND_poll() a number of times. If
112+
* RAND_poll() fails to generate seed data within the given amount of
113+
* retries, subsequent RAND_bytes() calls will fail, but we allow that to
114+
* happen to let pg_strong_random() callers handle that with appropriate
115+
* error handling.
112116
*/
113117
#define NUM_RAND_POLL_RETRIES 8
114118

@@ -120,16 +124,7 @@ pg_strong_random(void *buf, size_t len)
120124
break;
121125
}
122126

123-
if (RAND_poll() == 0)
124-
{
125-
/*
126-
* RAND_poll() failed to generate any seed data, which means that
127-
* RAND_bytes() will probably fail. For now, just fall through
128-
* and let that happen. XXX: maybe we could seed it some other
129-
* way.
130-
*/
131-
break;
132-
}
127+
RAND_poll();
133128
}
134129

135130
if (RAND_bytes(buf, len) == 1)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy