diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2016-06-14 14:31:35 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2016-06-14 14:31:35 (GMT) |
commit | b98a36e8f3006512f0fa4d94309fb9918eb8abdd (patch) | |
tree | 70145e9fc9f6bb7e0698abf2798f23e71a000681 /Python | |
parent | fd7f19ea67b0585929e723303c40de9153bba91d (diff) | |
download | cpython-b98a36e8f3006512f0fa4d94309fb9918eb8abdd.zip cpython-b98a36e8f3006512f0fa4d94309fb9918eb8abdd.tar.gz cpython-b98a36e8f3006512f0fa4d94309fb9918eb8abdd.tar.bz2 |
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.
Diffstat (limited to 'Python')
-rw-r--r-- | Python/random.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/Python/random.c b/Python/random.c index 07dacfe..b961020 100644 --- a/Python/random.c +++ b/Python/random.c @@ -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; |