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

Skip to content

Commit ec721f3

Browse files
committed
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.
1 parent adef646 commit ec721f3

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

Python/random.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ py_getrandom(void *buffer, Py_ssize_t size, int raise)
132132
* see https://bugs.python.org/issue26839. To avoid this, use the
133133
* GRND_NONBLOCK flag. */
134134
const int flags = GRND_NONBLOCK;
135-
int n;
135+
long n;
136136

137137
if (!getrandom_works)
138138
return 0;
@@ -143,7 +143,7 @@ py_getrandom(void *buffer, Py_ssize_t size, int raise)
143143
to 1024 bytes */
144144
n = Py_MIN(size, 1024);
145145
#else
146-
n = Py_MIN(size, INT_MAX);
146+
n = Py_MIN(size, LONG_MAX);
147147
#endif
148148

149149
errno = 0;

0 commit comments

Comments
 (0)