Fix os.urandom() using getrandom() on Linux
Issue #27278: Fix os.urandom() implementation using getrandom() on Linux. Truncate size to INT_MAX and loop until we collected enough random bytes, instead of casting a directly Py_ssize_t to int.
This commit is contained in:
@@ -143,7 +143,7 @@ py_getrandom(void *buffer, Py_ssize_t size, int raise)
|
||||
to 1024 bytes */
|
||||
n = Py_MIN(size, 1024);
|
||||
#else
|
||||
n = size;
|
||||
n = Py_MIN(size, INT_MAX);
|
||||
#endif
|
||||
|
||||
errno = 0;
|
||||
|
||||
Reference in New Issue
Block a user