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

Archive corrupted when contents added after header creation #282

Open
elbe0046 opened this issue Mar 3, 2022 · 0 comments
Open

Archive corrupted when contents added after header creation #282

elbe0046 opened this issue Mar 3, 2022 · 0 comments

Comments

@elbe0046
Copy link

elbe0046 commented Mar 3, 2022

If additional contents have been appended to a file after the Header is created but before the file contents are written to the archive the archive can become corrupted. Particularly if the additional contents straddle a 512-byte boundary.

Such that a tar -tf on the resulting archive reveals the following errors:

OS X

bugreport-3011000408-20220302_222509/logs/file1
tar: Damaged tar archive
tar: Retrying...

Linux

bugreport-3011000408-20220303_011636/logs/file1
tar: Skipping to next header

For example, this can happen when building an archive from log files, where processes are continually writing to the file even during the archiving process.

Upon inspecting a corrupted archive we see for a file file1 that has had additional contents written since header creation:

  • the header for file1 starts at 0x0032c400
  • the header size for file is 0x001C991B, so the next record should start at 0x004F5E00 (because this calculation is rounded up to the nearest 512 byte alignment)
  • And yet we see that the file1 contents exceed what the header specifies, ending at 0x00526A19
  • file2's header begins at 0x00526c00
elbe0046 added a commit to elbe0046/tar-rs that referenced this issue Mar 3, 2022
Addresses alexcrichton#282.

Signed-off-by: Grant Elbert <grant.elbert@smartthings.com>
@elbe0046 elbe0046 closed this as completed Mar 3, 2022
elbe0046 added a commit to elbe0046/tar-rs that referenced this issue Mar 3, 2022
Addresses alexcrichton#282.

Signed-off-by: Grant Elbert <grant.elbert@smartthings.com>
elbe0046 added a commit to elbe0046/tar-rs that referenced this issue Mar 3, 2022
Addresses alexcrichton#282.

Signed-off-by: Grant Elbert <grant.elbert@smartthings.com>
elbe0046 added a commit to elbe0046/tar-rs that referenced this issue Mar 3, 2022
Addresses alexcrichton#282.

Signed-off-by: Grant Elbert <grant.elbert@smartthings.com>
@elbe0046 elbe0046 reopened this Mar 4, 2022
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

1 participant