Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 370f513

Browse files
committed
Merge 3.5 (os.urandom, issue #27278)
2 parents 673ac27 + b98a36e commit 370f513

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

Misc/NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ What's New in Python 3.6.0 alpha 3
1010
Library
1111
-------
1212

13+
- Issue #27278: Fix os.urandom() implementation using getrandom() on Linux.
14+
Truncate size to INT_MAX and loop until we collected enough random bytes,
15+
instead of casting a directly Py_ssize_t to int.
16+
1317
- Issue #16864: sqlite3.Cursor.lastrowid now supports REPLACE statement.
1418
Initial patch by Alex LordThorsen.
1519

Python/random.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ py_getrandom(void *buffer, Py_ssize_t size, int raise)
146146
to 1024 bytes */
147147
n = Py_MIN(size, 1024);
148148
#else
149-
n = size;
149+
n = Py_MIN(size, INT_MAX);
150150
#endif
151151

152152
errno = 0;

0 commit comments

Comments
 (0)