Skip to content

Commit 077d01f

Browse files
committed
random: only use getentropy on openbsd
1 parent 0b01935 commit 077d01f

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/random.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,10 +227,12 @@ void GetOSRand(unsigned char *ent32)
227227
RandFailure();
228228
}
229229
}
230-
#elif defined(HAVE_GETENTROPY)
230+
#elif defined(HAVE_GETENTROPY) && defined(__OpenBSD__)
231231
/* On OpenBSD this can return up to 256 bytes of entropy, will return an
232232
* error if more are requested.
233233
* The call cannot return less than the requested number of bytes.
234+
getentropy is explicitly limited to openbsd here, as a similar (but not
235+
the same) function may exist on other platforms via glibc.
234236
*/
235237
if (getentropy(ent32, NUM_OS_RANDOM_BYTES) != 0) {
236238
RandFailure();

0 commit comments

Comments
 (0)