summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Misc/NEWS4
-rw-r--r--Python/random.c2
2 files changed, 5 insertions, 1 deletions
diff --git a/Misc/NEWS b/Misc/NEWS
index bf7b8f1..7311a65 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -10,6 +10,10 @@ What's New in Python 3.6.0 alpha 3
Library
-------
+- 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.
+
- Issue #16864: sqlite3.Cursor.lastrowid now supports REPLACE statement.
Initial patch by Alex LordThorsen.
diff --git a/Python/random.c b/Python/random.c
index e4f1e7a..cbdebbe 100644
--- a/Python/random.c
+++ b/Python/random.c
@@ -146,7 +146,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;