-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
std: Cap read/write limits on Windows networking #31858
Conversation
cc @ollie27 |
r? @brson (rust_highfive has picked a reviewer for you, use r? to override) |
@@ -131,9 +132,9 @@ impl Socket { | |||
pub fn read(&self, buf: &mut [u8]) -> io::Result<usize> { | |||
// On unix when a socket is shut down all further reads return 0, so we | |||
// do the same on windows to map a shut down socket to returning EOF. | |||
let len = cmp::min(buf.len(), i32::max_value()) as i32; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is missing an as usize
.
May as well make this line match the others:
let len = cmp::min(buf.len(), <wrlen_t>::max_value() as usize) as wrlen_t;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh oops good catch! I also figured it's better to use i32
here as it's what's actually required for the system call (eg this is windows specific).
I'm not a huge fan of the usage of wrlen_t
in general unfortunately...
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
8bccee6
to
f3be73c
Compare
@bors r+ |
📌 Commit f3be73c has been approved by |
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
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 onWindows this will cap the read/write amounts to
i32::max_value
.cc #31841