mirror of
https://github.com/AdaCore/cpython.git
synced 2026-02-12 12:57:15 -08:00
Issue #22181: Fix dev_urandom_noraise(), try calling py_getrandom() before
opening /dev/urandom.
This commit is contained in:
@@ -166,10 +166,6 @@ dev_urandom_noraise(unsigned char *buffer, Py_ssize_t size)
|
||||
|
||||
assert (0 < size);
|
||||
|
||||
fd = _Py_open_noraise("/dev/urandom", O_RDONLY);
|
||||
if (fd < 0)
|
||||
Py_FatalError("Failed to open /dev/urandom");
|
||||
|
||||
#ifdef HAVE_GETRANDOM_SYSCALL
|
||||
if (py_getrandom(buffer, size, 0) == 1)
|
||||
return;
|
||||
@@ -177,6 +173,10 @@ dev_urandom_noraise(unsigned char *buffer, Py_ssize_t size)
|
||||
* on reading /dev/urandom */
|
||||
#endif
|
||||
|
||||
fd = _Py_open_noraise("/dev/urandom", O_RDONLY);
|
||||
if (fd < 0)
|
||||
Py_FatalError("Failed to open /dev/urandom");
|
||||
|
||||
while (0 < size)
|
||||
{
|
||||
do {
|
||||
|
||||
Reference in New Issue
Block a user