mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
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.
This commit is contained in:
parent
adef6460d7
commit
ec721f3305
1 changed files with 2 additions and 2 deletions
|
@ -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
|
* see https://bugs.python.org/issue26839. To avoid this, use the
|
||||||
* GRND_NONBLOCK flag. */
|
* GRND_NONBLOCK flag. */
|
||||||
const int flags = GRND_NONBLOCK;
|
const int flags = GRND_NONBLOCK;
|
||||||
int n;
|
long n;
|
||||||
|
|
||||||
if (!getrandom_works)
|
if (!getrandom_works)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -143,7 +143,7 @@ py_getrandom(void *buffer, Py_ssize_t size, int raise)
|
||||||
to 1024 bytes */
|
to 1024 bytes */
|
||||||
n = Py_MIN(size, 1024);
|
n = Py_MIN(size, 1024);
|
||||||
#else
|
#else
|
||||||
n = Py_MIN(size, INT_MAX);
|
n = Py_MIN(size, LONG_MAX);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
errno = 0;
|
errno = 0;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue