Comments (9)
Here is the source code https://github.com/axetroy/cask.rs/blob/main/src/extractor.rs
I tried to give a minimum implementation for reproduce
from libflate.
Thank you for reporting this issue.
However, I could not reproduce your problem.
I wrote the following code that deflates the above input file then prints the original size:
fn main() -> anyhow::Result<()> {
let tar_file = std::fs::File::open("prune_darwin_amd64.tar.gz")?;
let mut input = libflate::gzip::Decoder::new(&tar_file)?;
let mut output = Vec::new();
std::io::copy(&mut input, &mut output)?;
println!("Deflated size: {}", output.len());
Ok(())
}
// The comment below is the output of this command.
// Deflated size: 968192
Then, I applied gzip
command to deflate the file then confirmed the result file size by using ls
:
$ gzip -d prune_darwin_amd64.tar.gz
$ ls -l
-rw-r--r-- 1 user user 968192 Feb 28 02:19 prune_darwin_amd64.tar
So the two results seem matched.
from libflate.
BTW, I could not run the code snippet you shared as I don't know where the Archive
struct (or enum?) comes from.
from libflate.
@sile Hello, Thanks for your help.
And here is the reproduced repo: https://github.com/axetroy/libflate-66
git clone https://github.com/axetroy/libflate-66
cd ./libflate-66
cargo run ./
# View unzipped files βpruneβ
from libflate.
Thank you for the additional information. I could reproduce your result.
Then, I modified the code to use the file ("prune_darwin_amd64.tar") directly deflated by gzip
command as follows:
fn main() -> anyhow::Result<()> {
let extract_file_name = "prune";
let output_file_path = "output";
let mut archive = Archive::new(std::fs::File::open("prune_darwin_amd64.tar")?);
archive.set_unpack_xattrs(true);
archive.set_overwrite(true);
archive.set_preserve_permissions(true);
archive.set_preserve_mtime(true);
let files = archive.entries()?;
for entry in files {
let mut file = entry?;
let file_path = file.path()?;
if let Some(file_name) = file_path.file_name() {
dbg!(&file_name);
if file_name.to_str().unwrap() == extract_file_name {
file.unpack(&output_file_path)?;
print!("unpacked");
break;
}
}
}
Ok(())
}
The result was unchanged (i.e., the unpacked file size was 965,416). Thus this is not a problem relevant to libflate
I think.
from libflate.
This makes me confused
I use GZ to compress the file, then decompress it, the result is correct.
I use the TAR archive, then decompress it, the result is correct.
But I combined them, the result is incorrect.
But installing the unzipping tools installed on my computer, everything is fine
from libflate.
FYI, Python3's tar library could handle the (already deflated) input tar file correctly.
>>> import tarfile
>>> tar = tarfile.open("prune_darwin_amd64.tar")
>>> tar.getmember("prune").size
985384
from libflate.
OK, it should be the difference between TAR implementation.
Thanks for your help and time. Have a good day π
from libflate.
π
from libflate.
Related Issues (20)
- Decoder may expose contents of uninitialized memory in the output HOT 5
- Use-after-free on panic in client code HOT 4
- Remove byteorder-dependency HOT 1
- Possible concurrency issue during deflate on libflate 0.1.25 HOT 8
- Convenience functions? HOT 1
- btype 0x11 of DEFLATE is reserved(error) value HOT 1
- LZ77 compressor as a separate crate? HOT 3
- libflate 1.0.0 is on crates.io, but not here HOT 1
- Encoder panic on specific input data... HOT 1
- Compression level HOT 5
- UnexpectedEof encountered when decompressing data HOT 4
- Streaming data extensions HOT 4
- LZ77 decoder? HOT 2
- libflate::gzip::Decoder::read does not handle zero-length buffer properly HOT 2
- UB in the public safe API - where to report? HOT 4
- Panic in `bug` when parsing malformed file HOT 4
- Error while decoding just encoded data HOT 2
- zLib decoding fails with failed to fill whole buffer HOT 6
- MultiGzDecoder with non-gzip bytes at end
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from libflate.