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

Windows: buffer uninitialized if longer than 2^32 bytes #31

Closed
josephlr opened this issue Jun 14, 2019 · 2 comments · Fixed by #33
Closed

Windows: buffer uninitialized if longer than 2^32 bytes #31

josephlr opened this issue Jun 14, 2019 · 2 comments · Fixed by #33

Comments

@josephlr
Copy link
Member

josephlr commented Jun 14, 2019

The Windows implementation for getrandom_inner() calls RtlGenRandom. However, the length parameter is a ULONG (i.e. a u32).

Thus, if a buffer of length 2^32 is passed to getrandom() on Windows, the call dest.len() as ULONG truncates the value to 0. This results in the function seeming to succeed, but without writing any data.

Thanks to @briansmith's ring implementation, for pointing this out.

@dhardy
Copy link
Member

dhardy commented Jun 14, 2019

So the ring implementation just truncates large requests to 4 GiB? We use .chunks_mut for several backends already, so should just to the same here.

@newpavlov
Copy link
Member

Good catch! Yes, chunks_mut(u32::MAX) looks like a good solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants