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(tar): clear rest of buffer when eof is reached #789

Merged
merged 2 commits into from
Oct 20, 2022
Merged

Conversation

piksel
Copy link
Member

@piksel piksel commented Oct 20, 2022

When reading a tar file using TarBuffer and the EOF was reached before a full record could be read, the ReadRecordAsync method still treats it as a successful read, by assuming the rest of the buffer just contained zeros.

This is not necessarily the case with a SharedArray buffer, which it currently uses. This PR makes sure that the rest of the buffer is cleared before returning.

Fixes #782.

@codecov
Copy link

codecov bot commented Oct 20, 2022

Codecov Report

Merging #789 (12cc7be) into master (6c96ce2) will decrease coverage by 0.00%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master     #789      +/-   ##
==========================================
- Coverage   74.71%   74.71%   -0.01%     
==========================================
  Files          72       72              
  Lines        8465     8468       +3     
==========================================
+ Hits         6325     6327       +2     
- Misses       2140     2141       +1     
Impacted Files Coverage Δ
src/ICSharpCode.SharpZipLib/Tar/TarBuffer.cs 73.61% <100.00%> (+0.49%) ⬆️
...Code.SharpZipLib/Zip/Compression/DeflaterEngine.cs 85.66% <0.00%> (-0.38%) ⬇️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@piksel piksel merged commit 75d1cf8 into master Oct 20, 2022
@piksel piksel deleted the fix/empty-tar-read branch October 20, 2022 09:40
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.

Exception thrown (rarely) in TarHeader with empty array
1 participant