JuliaIO / Tar.jl

TAR files: create, list, extract them in pure Julia
MIT License
79 stars 19 forks source link

Fix padding assertion errors #65

Closed staticfloat closed 4 years ago

staticfloat commented 4 years ago

Tar formats pad their inputs with zeros to have all content aligned to a certain block size; when extracting data, we used a while loop to iterate until we had consumed all non-padded data within the stream, when we actually needed to iterate until we had consumed all of the zero-padded data as well. This was only an issue when the stream buffering lined up such that a readbytes!() call ends with reading all nonzero content, but not all zero-padding.

To test this, I have added a buffer stream type that allows us to control the number of bytes returned from a read operation, as well as allowing it to be randomized, for some simple fuzzing.

codecov[bot] commented 4 years ago

Codecov Report

Merging #65 into master will not change coverage. The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master      #65   +/-   ##
=======================================
  Coverage   95.84%   95.84%           
=======================================
  Files           4        4           
  Lines         578      578           
=======================================
  Hits          554      554           
  Misses         24       24           
Impacted Files Coverage Δ
src/extract.jl 95.43% <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 304c8bd...1064f35. Read the comment docs.