mirror of
https://github.com/python/cpython.git
synced 2025-09-26 10:19:53 +00:00
Issue #25003: os.urandom() doesn't use getentropy() on Solaris because
getentropy() is blocking, whereas os.urandom() should not block. getentropy() is supported since Solaris 11.3.
This commit is contained in:
parent
3f18f10f39
commit
78cc2e8968
2 changed files with 12 additions and 4 deletions
|
@ -10,6 +10,10 @@ Release date: tba
|
||||||
Core and Builtins
|
Core and Builtins
|
||||||
-----------------
|
-----------------
|
||||||
|
|
||||||
|
- Issue #25003: os.urandom() doesn't use getentropy() on Solaris because
|
||||||
|
getentropy() is blocking, whereas os.urandom() should not block. getentropy()
|
||||||
|
is supported since Solaris 11.3.
|
||||||
|
|
||||||
- Issue #25182: The stdprinter (used as sys.stderr before the io module is
|
- Issue #25182: The stdprinter (used as sys.stderr before the io module is
|
||||||
imported at startup) now uses the backslashreplace error handler.
|
imported at startup) now uses the backslashreplace error handler.
|
||||||
|
|
||||||
|
|
|
@ -67,7 +67,11 @@ win32_urandom(unsigned char *buffer, Py_ssize_t size, int raise)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#elif HAVE_GETENTROPY
|
/* Issue #25003: Don' use getentropy() on Solaris (available since
|
||||||
|
* Solaris 11.3), it is blocking whereas os.urandom() should not block. */
|
||||||
|
#elif defined(HAVE_GETENTROPY) && !defined(sun)
|
||||||
|
#define PY_GETENTROPY 1
|
||||||
|
|
||||||
/* Fill buffer with size pseudo-random bytes generated by getentropy().
|
/* Fill buffer with size pseudo-random bytes generated by getentropy().
|
||||||
Return 0 on success, or raise an exception and return -1 on error.
|
Return 0 on success, or raise an exception and return -1 on error.
|
||||||
|
|
||||||
|
@ -275,7 +279,7 @@ _PyOS_URandom(void *buffer, Py_ssize_t size)
|
||||||
|
|
||||||
#ifdef MS_WINDOWS
|
#ifdef MS_WINDOWS
|
||||||
return win32_urandom((unsigned char *)buffer, size, 1);
|
return win32_urandom((unsigned char *)buffer, size, 1);
|
||||||
#elif HAVE_GETENTROPY
|
#elif defined(PY_GETENTROPY)
|
||||||
return py_getentropy(buffer, size, 0);
|
return py_getentropy(buffer, size, 0);
|
||||||
#else
|
#else
|
||||||
return dev_urandom_python((char*)buffer, size);
|
return dev_urandom_python((char*)buffer, size);
|
||||||
|
@ -322,7 +326,7 @@ _PyRandom_Init(void)
|
||||||
else {
|
else {
|
||||||
#ifdef MS_WINDOWS
|
#ifdef MS_WINDOWS
|
||||||
(void)win32_urandom(secret, secret_size, 0);
|
(void)win32_urandom(secret, secret_size, 0);
|
||||||
#elif HAVE_GETENTROPY
|
#elif defined(PY_GETENTROPY)
|
||||||
(void)py_getentropy(secret, secret_size, 1);
|
(void)py_getentropy(secret, secret_size, 1);
|
||||||
#else
|
#else
|
||||||
dev_urandom_noraise(secret, secret_size);
|
dev_urandom_noraise(secret, secret_size);
|
||||||
|
@ -338,7 +342,7 @@ _PyRandom_Fini(void)
|
||||||
CryptReleaseContext(hCryptProv, 0);
|
CryptReleaseContext(hCryptProv, 0);
|
||||||
hCryptProv = 0;
|
hCryptProv = 0;
|
||||||
}
|
}
|
||||||
#elif HAVE_GETENTROPY
|
#elif defined(PY_GETENTROPY)
|
||||||
/* nothing to clean */
|
/* nothing to clean */
|
||||||
#else
|
#else
|
||||||
dev_urandom_close();
|
dev_urandom_close();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue