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

Fix reading/writing 4 GiB or larger files on Windows 64-bit #31825

Merged
merged 1 commit into from
Feb 23, 2016

Conversation

ollie27
Copy link
Member

@ollie27 ollie27 commented Feb 23, 2016

ReadFile and WriteFile take a DWORD (u32) for the length argument
which was erroneously cast from a usize causing truncation. This meant
methods like write_all and read_exact would unexpectedly fail if
given a buffer 4 GiB or larger.

We can instead just ask for u32::MAX bytes if the given buffer is too
big.

`ReadFile` and `WriteFile` take a DWORD (u32) for the length argument
which was erroneously cast from a usize causing truncation. This meant
methods like `write_all` and `read_exact` would unexpectedly fail if
given a buffer 4 GiB or larger.

We can instead just ask for `u32::MAX` bytes if the given buffer is too
big.
@rust-highfive
Copy link
Collaborator

r? @brson

(rust_highfive has picked a reviewer for you, use r? to override)

@alexcrichton
Copy link
Member

@bors: r+ b340f25

Thanks! There may also be some places in the networking types which need this treatment?

@bors
Copy link
Contributor

bors commented Feb 23, 2016

⌛ Testing commit b340f25 with merge 0de3cac...

bors added a commit that referenced this pull request Feb 23, 2016
`ReadFile` and `WriteFile` take a DWORD (u32) for the length argument
which was erroneously cast from a usize causing truncation. This meant
methods like `write_all` and `read_exact` would unexpectedly fail if
given a buffer 4 GiB or larger.

We can instead just ask for `u32::MAX` bytes if the given buffer is too
big.
@ollie27
Copy link
Member Author

ollie27 commented Feb 23, 2016

It looks like there are other issues, I've opened an issue #31841.

@bors bors merged commit b340f25 into rust-lang:master Feb 23, 2016
alexcrichton added a commit to alexcrichton/rust that referenced this pull request 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 pull request 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
@ollie27 ollie27 deleted the win_lfs branch May 2, 2016 18:05
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 this pull request may close these issues.

5 participants