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

more than 8Go file support and data corruption #188

Closed
Akos13 opened this issue Jun 22, 2018 · 2 comments
Closed

more than 8Go file support and data corruption #188

Akos13 opened this issue Jun 22, 2018 · 2 comments

Comments

@Akos13
Copy link

Akos13 commented Jun 22, 2018

Hello,
When creating tar with file bigger than 8Go, tar end of file is invalid and file datas are corrupted.
i know that gnu tar spécification support this point, but it seems not be implemented in this lib.
Bug or choice of tar version specification or bad usage?
thanks!

@justfalter
Copy link
Contributor

I believe that @Akos13 is saying that they are unable to extra gnu-tar formatted tar files that contain files > 8gb. I've seen this, as well, using node-tar 4.4.8.

To reproduce the issue, I used gnu tar 1.32. On my mac, I installed via brew install gnu-tar, which installs /usr/local/bin/gtar

$ gtar --version
tar (GNU tar) 1.32
Copyright (C) 2019 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by John Gilmore and Jay Fenlason.

Add an 8GB (or greater) file to a gnu-formatted tarball. This ensures that the file size is encoded in base-256:

$ dd if=/dev/zero of=bigfile.dat bs=1048576 count=8192
8192+0 records in                                                    
8192+0 records out                                                
8589934592 bytes transferred in 20.246523 secs (424267146 bytes/sec)

$ gtar cvvf test.tar --format gnu  bigfile.dat
-rw-r--r-- mike.ryan/staff 8589934592 2019-05-30 11:58 bigfile.dat    

Here's the script I use to extract:

const tar = require('tar');
const fs = require('fs');
const rimraf = require('rimraf');

if (fs.existsSync('output')) {
  rimraf.sync('output');
}

fs.mkdirSync('output');

fs.createReadStream('test.tar')
  .pipe(
    tar.x( {
      C: 'output',
      onwarn: function(message, data) {
        console.log(`WARNING: ${message}`);
      },
      onentry: function(entry) {
        console.log(`Extracting: ${entry.path}: ${entry.size}`);
      },
    }));

The output:

$ time node test.js 
Extracting: bigfile.dat: 33554432

And the file output/bigfile.dat is created with 33554432 bytes, where 8589934592 were expected.

The core the issue is that base-256 encoding/decoding of numbers in node-tar is broken. I'm about to submit a PR that fixes this.

@isaacs
Copy link
Owner

isaacs commented Jun 4, 2019

I believe that this should be fixed by #215. Can you try on the latest release?

@isaacs isaacs closed this as completed Jun 4, 2019
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

No branches or pull requests

3 participants