-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Allow writes of length 0 to a full buffer #15592
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
Conversation
Could you add a test for this as well? |
Yeah just remembered, working on that |
You'd write (re-post comment from changed diff to here) |
Added test and changed condition to @blake2-ppc suggestion |
Looks like there ia a problem with a @blake2-ppc suggestion because seeking beyond end of buffer is allowed and all the lengths are unsigned. |
True, I'm sorry for that; the conditional needs an invariant that Seek doesn't keep in place. The fact remains that the original condition is an "overflow trigger", a pattern that usually has an overflow problem. In the past I fixed a lot of overflow problems with vectors -- Rust code would write overflowing calculations and head directly into unsafe code with those invalid values (allowing crashes or arbitrary memory clobbering). Since there's always a risk that later changes add unsafe sections to some parts of the implementation of for example BufWriter, it remains important to think about arithmetic wraparound / overflow. |
That was just a statement after finding a problem until I fix it, not blaming you. |
That build error just travis issues? @alexcrichton |
First condition is not needed and just prevents 0 length writes Fixes #15583
Shrink some stuff
First condition is not needed and just prevents 0 length writes
Fixes #15583