diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2016-06-14 16:31:35 +0200 |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2016-06-14 16:31:35 +0200 |
commit | 2a8684b783b2cc31e76c6929d5c263ab370aeae1 (patch) | |
tree | 2b5db7bd2c7a5167fff312135490cbba91d035e8 /Python/random.c | |
parent | 5e250600457f9190fae25eb745dd8b261e8d7586 (diff) | |
download | cpython-2a8684b783b2cc31e76c6929d5c263ab370aeae1.tar.gz |
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/random.c')
-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 07dacfe188..b9610208f6 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; |