summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2016-06-14 14:33:17 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2016-06-14 14:33:17 (GMT)
commit370f5136d4c82778eabd9d808f6e73f6b9a8fad4 (patch)
treecd3bb79b778b554d8ef280f55dcf46132474f432
parent673ac2749943d4077137984a640e8f6eb2f43a26 (diff)
parentb98a36e8f3006512f0fa4d94309fb9918eb8abdd (diff)
downloadcpython-370f5136d4c82778eabd9d808f6e73f6b9a8fad4.zip
cpython-370f5136d4c82778eabd9d808f6e73f6b9a8fad4.tar.gz
cpython-370f5136d4c82778eabd9d808f6e73f6b9a8fad4.tar.bz2
Merge 3.5 (os.urandom, issue #27278)
-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;