Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bpo-18407: win32_urandom() uses PY_DWORD_MAX #10656

Merged
merged 2 commits into from
Nov 22, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
bpo-18407: win32_urandom() uses PY_DWORD_MAX
CryptGenRandom() maximum size is PY_DWORD_MAX, not INT_MAX.

Co-Authored-By: Jeremy Kloth <[email protected]>
  • Loading branch information
vstinner and jkloth committed Nov 22, 2018
commit c25d9718b7d8c93737b04a10463379c5be671c60
2 changes: 1 addition & 1 deletion Python/bootstrap_hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ win32_urandom(unsigned char *buffer, Py_ssize_t size, int raise)

while (size > 0)
{
chunk = size > INT_MAX ? INT_MAX : size;
chunk = Py_MIN(size, PY_DWORD_MAX);
if (!CryptGenRandom(hCryptProv, (DWORD)chunk, buffer))
{
/* CryptGenRandom() failed */
Expand Down