summaryrefslogtreecommitdiffstats
path: root/Python/random.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2016-06-16 21:53:47 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2016-06-16 21:53:47 (GMT)
commitec721f3305c04b5d136e2d21cb73c5bdfdd81684 (patch)
treeb931eb1fd826a80a73d27279ea4d9f2a8d095ca5 /Python/random.c
parentadef6460d73ce1ab33af9c9ef014aa88f23c6d62 (diff)
downloadcpython-ec721f3305c04b5d136e2d21cb73c5bdfdd81684.zip
cpython-ec721f3305c04b5d136e2d21cb73c5bdfdd81684.tar.gz
cpython-ec721f3305c04b5d136e2d21cb73c5bdfdd81684.tar.bz2
py_getrandom(): use long type for the syscall() result
Issue #27278. It should fix a conversion warning. In practice, the Linux kernel doesn't return more than 32 MB per call to the getrandom() syscall.
Diffstat (limited to 'Python/random.c')
-rw-r--r--Python/random.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/Python/random.c b/Python/random.c
index 8ce0b3e..3119872 100644
--- a/Python/random.c
+++ b/Python/random.c
@@ -132,7 +132,7 @@ py_getrandom(void *buffer, Py_ssize_t size, int raise)
* see https://bugs.python.org/issue26839. To avoid this, use the
* GRND_NONBLOCK flag. */
const int flags = GRND_NONBLOCK;
- int n;
+ long n;
if (!getrandom_works)
return 0;
@@ -143,7 +143,7 @@ py_getrandom(void *buffer, Py_ssize_t size, int raise)
to 1024 bytes */
n = Py_MIN(size, 1024);
#else
- n = Py_MIN(size, INT_MAX);
+ n = Py_MIN(size, LONG_MAX);
#endif
errno = 0;