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

Incorrect integer casts for some Windows APIs #31841

Closed
3 tasks done
ollie27 opened this issue Feb 23, 2016 · 1 comment
Closed
3 tasks done

Incorrect integer casts for some Windows APIs #31841

ollie27 opened this issue Feb 23, 2016 · 1 comment

Comments

@ollie27
Copy link
Member

ollie27 commented Feb 23, 2016

In a few places in std there are casts from usize to u32 or i32 for Windows APIs which causes breakage on 64-bit.

Some examples I have found so far:

There may be more.

alexcrichton added a commit to alexcrichton/rust that referenced this issue Feb 24, 2016
Similar to rust-lang#31825 where the read/write limits were capped for files, this
implements similar limits when reading/writing networking types. On Unix this
shouldn't affect anything because the write size is already a `usize`, but on
Windows this will cap the read/write amounts to `i32::max_value`.

cc rust-lang#31841
bors added a commit that referenced this issue Feb 26, 2016
Similar to #31825 where the read/write limits were capped for files, this
implements similar limits when reading/writing networking types. On Unix this
shouldn't affect anything because the write size is already a `usize`, but on
Windows this will cap the read/write amounts to `i32::max_value`.

cc #31841
bors added a commit that referenced this issue Feb 26, 2016
CryptGenRandom takes a DWORD (u32) for the length so it only supports
writing u32::MAX bytes at a time.

Casting the length from a usize caused truncation meaning the whole
buffer was not always filled.

cc #31841

This is the same as rust-random/rand#99. I think it's a good idea to keep the implementations in sync.

r? @alexcrichton
@ollie27
Copy link
Member Author

ollie27 commented Mar 3, 2016

Well I didn't find any more so I'll close this.

@ollie27 ollie27 closed this as completed Mar 3, 2016
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

No branches or pull requests

1 participant