[Python-checkins] cpython (merge 3.5 -> default): Merge 3.5 (os.urandom, issue #27278)

victor.stinner python-checkins at python.org
Tue Jun 14 10:34:09 EDT 2016


https://hg.python.org/cpython/rev/0d39bd9028e8
changeset: 102034:0d39bd9028e8
parent: 102032:1f376758837d
parent: 102033:e028e86a5b73
user: Victor Stinner <victor.stinner at gmail.com>
date: Tue Jun 14 16:33:17 2016 +0200
summary:
 Merge 3.5 (os.urandom, issue #27278)
files:
 Misc/NEWS | 4 ++++
 Python/random.c | 2 +-
 2 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -10,6 +10,10 @@
 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
--- a/Python/random.c
+++ b/Python/random.c
@@ -146,7 +146,7 @@
 to 1024 bytes */
 n = Py_MIN(size, 1024);
 #else
- n = size;
+ n = Py_MIN(size, INT_MAX);
 #endif
 
 errno = 0;
-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /