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

BufWriter panics with small writes #12

Open
seritools opened this issue Sep 30, 2021 · 0 comments
Open

BufWriter panics with small writes #12

seritools opened this issue Sep 30, 2021 · 0 comments

Comments

@seritools
Copy link

seritools commented Sep 30, 2021

https://github.com/technocreatives/core2/blob/d2d4681c13dfef88ac5fe0ced8d3cb98ccdee85c/src/io/buffered.rs#L612-613
https://github.com/technocreatives/core2/blob/d2d4681c13dfef88ac5fe0ced8d3cb98ccdee85c/src/io/buffered.rs#L631-633

copy_from_slice panics if the slices are of different length. The code does not limit self.buf to the correct slice offset and length needed for this call to ever succeed.

I think it should have been something like

self.buf[self.len..][..buf.len()].copy_from_slice(buf);

Maybe it makes sense to grab the implementation for that from the current stdlib code?

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