alexcrichton / tar-rs

Tar file reading/writing for Rust
https://docs.rs/tar
Apache License 2.0
616 stars 178 forks source link

`Builder::append_*` methods corrupt archive when file size changes #352

Open tp971 opened 7 months ago

tp971 commented 7 months ago

When using Builder::append_path (or any of the append methods except append_link), if the file size changes during the archival, it will corrupt the archive. The GNU tar implementation seems to handle this by limiting the amount of bytes written to the archive in case the file got bigger, or padding it with zeroes if the file got smaller.

It is possible to work around this issue by calling append_data with a manually generated header and a wrapper around Read that limits the amount of bytes or returns padding zeroes, however it would be nice if this case is handled by tar::Builder.