Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit15e4419

Browse files
committed
Remove optimization for RAND_poll() failing.
The loop to generate seed data will exit on RAND_status(), so we don'tneed to handle the case of RAND_poll() failing separately. Failureshere 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 parentce4939f commit15e4419

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
#defineNUM_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)

[8]ページ先頭

©2009-2025 Movatter.jp