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

bufread::generic::Decoder: don't reinitialize on reader EOF #148

Closed
wants to merge 3 commits into from

Conversation

eeeeeta
Copy link
Contributor

@eeeeeta eeeeeta commented May 12, 2022

If multiple_members is enabled, the bufread::generic::Decoder will
attempt to reinitialise the decoder inside State::Flushing, even if
the reason it entered that state was due to the reader returning an EOF.
This will result in an attempt to read past EOF, which is highly
undesirable to say the least.

To fix this, force multiple_members to false when we get an EOF
condition from the reader.

@Nemo157
Copy link
Member

Nemo157 commented May 13, 2022

To understand the issue I added an additional test assertion that I believe covers what this is meant to fix: bd6f0ae. If that looks like what you saw you can cherry-pick it to your branch.

If `multiple_members` is enabled, the `bufread::generic::Decoder` will
attempt to reinitialise the decoder inside `State::Flushing`, even if
the reason it entered that state was due to the reader returning an EOF.
This will result in an attempt to read past EOF, which is highly
undesirable to say the least.

To fix this, force `multiple_members` to `false` when we get an EOF
condition from the reader.
@eeeeeta
Copy link
Contributor Author

eeeeeta commented May 13, 2022

@Nemo157 Yeah, that test looks good! Cherry-picked (and fixed the stupid compilation error :p)

@Nemo157
Copy link
Member

Nemo157 commented May 15, 2022

I fixed my tests formatting and just applied the same change to all the implementations.

bors r+

bors bot added a commit that referenced this pull request May 15, 2022
148: bufread::generic::Decoder: don't reinitialize on reader EOF r=Nemo157 a=eeeeeta

If `multiple_members` is enabled, the `bufread::generic::Decoder` will
attempt to reinitialise the decoder inside `State::Flushing`, even if
the reason it entered that state was due to the reader returning an EOF.
This will result in an attempt to read past EOF, which is highly
undesirable to say the least.

To fix this, force `multiple_members` to `false` when we get an EOF
condition from the reader.

Co-authored-by: eta <github@eta.st>
Co-authored-by: Wim Looman <git@nemo157.com>
@codecov-commenter
Copy link

Codecov Report

Merging #148 (e724673) into prīmum (6104f83) will increase coverage by 0.52%.
The diff coverage is 95.78%.

@@            Coverage Diff             @@
##           prīmum     #148      +/-   ##
==========================================
+ Coverage   78.00%   78.52%   +0.52%     
==========================================
  Files          92       93       +1     
  Lines        2950     3041      +91     
==========================================
+ Hits         2301     2388      +87     
- Misses        649      653       +4     
Impacted Files Coverage Δ
tests/utils/mod.rs 100.00% <ø> (ø)
tests/utils/track_eof.rs 95.34% <95.34%> (ø)
src/futures/bufread/generic/decoder.rs 76.47% <100.00%> (+0.47%) ⬆️
src/tokio/bufread/generic/decoder.rs 75.92% <100.00%> (+0.45%) ⬆️
src/tokio_02/bufread/generic/decoder.rs 76.47% <100.00%> (+0.47%) ⬆️
src/tokio_03/bufread/generic/decoder.rs 75.92% <100.00%> (+0.45%) ⬆️
tests/utils/impls.rs 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6104f83...e724673. Read the comment docs.

@bors bors bot closed this May 15, 2022
@eeeeeta
Copy link
Contributor Author

eeeeeta commented May 17, 2022

Thanks, @Nemo157! Would you mind cutting a new release and pushing it to crates.io? (we're using your crate in arti, and not having a git dependency would be nice!)

@eeeeeta eeeeeta deleted the no-read-after-eof branch May 17, 2022 13:20
@Nemo157
Copy link
Member

Nemo157 commented May 19, 2022

Published 0.3.14

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.

None yet

3 participants