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

Error: Invalid tar header. Maybe the tar is corrupted or it needs to be gunzipped? #110

Closed
palavrov opened this issue Jan 26, 2020 · 7 comments

Comments

@palavrov
Copy link

tar-stream/extract.js

Lines 180 to 181 in b737a8d

self.emit('entry', header, self._stream, onunlock)
self._parse(header.size, onstreamend)

If header.size is modified for some reason in entry event handler causes this error. For now quick fix is just to avoid modifying the header.size in the event handler but at least it needs to be documented or even better to make and use a copy of the size in local variable.

palavrov added a commit to treedys/postpack that referenced this issue Jan 26, 2020
@PaulMcGuinness
Copy link

I'm getting this error on certain tar file that unpacks perfectly fine using other tools, any thoughts? (I've zipped it up to attach it here) - The tar's come from a vxWorks platform if that helps?

backup_dbsave_cfg1sw4_11.0.2.82_20150609084847.tar.zip

@palavrov
Copy link
Author

@PaulMcGuinness, the issue I got was caused by me modifying tar-stream header.size variable. If your code is modifying this variable too could be a good reason for this error message.

@PaulMcGuinness
Copy link

No, not doing any modifications. Using the simple example code. It's definitely tar version related (as newer versions of the same platform's backup work fine)

@palavrov
Copy link
Author

palavrov commented Jan 25, 2021

So ... I debugged a bit and got the problem - your tar file fails the proper header checks ( look here if you are curious

if (USTAR_MAGIC.compare(buf, MAGIC_OFFSET, MAGIC_OFFSET + 6) === 0) {
).

Solution is to:

  1. Conform with the expected tar file format.
  2. Pass to extract({allowUnknownFormat:true})
  3. Do a PR here with a fix how to detect the header

I would suggest to go for 1

@PaulMcGuinness
Copy link

Many thanks for the solutions - I can't change the tar format, and (3) is outside my abilities, so I'll try (2) tomorrow :-)

@PaulMcGuinness
Copy link

Option (2) worked perfectly - Many thanks! :-)

@mafintosh
Copy link
Owner

If you wanna add a note about that to the readme send a PR 😊

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