shouldn't tar quit at end of archive?

Mihai Buha mihai.buha at nivis.com
Thu Apr 6 09:05:35 UTC 2006


Hi Paul,

> From: Paul Fox [mailto:pgf at brightstareng.com] 
<snip>
> second, it causes tar to exit when it detects the first occurence
> of a null header in the archive, rather than waiting for the
> second such header.  not all tar archives are terminated with two
> null headers.

Look at this: http://www.busybox.net/lists/busybox/2001-May/003341.html
Maybe this is the original reason why it tried to read everything
past the first empty block.

> ironically, i was the last person to touch the lines i'm now
> changing, when i commited the patch that was submitted with bug
> 262.  before that patch, tar also attempted to read all of
> the data in the file, but if it happened that there was non-zero
> data after the end-of-archive had been detected, tar would resume
> trying to interpret that data.  the fix for 262 addressed that
> issue, at the expense of requiring the doubled null block at the
> end.

I reported that bug and wrote that patch. I did it after reading
http://www.gnu.org/software/tar/manual/html_node/Standard.html
"At the end of the archive file there are two 512-byte blocks
filled with binary zeros as an end-of-file marker [...] When
reading an archive, a reasonable system should properly handle
an archive [...] which contains garbage records after a zero
block." I see now that busybox doesn't actually verify that the
two blocks are "filled with binary zeros", but only that there
is no filename in those blocks, so my patch is not, after all,
"standards compliant".

> one thing i don't understand about the current code is the comment
> regarding emptying the gz or bz2 pipe.  when or why would this be
> an issue?

We use "tar xzf file.tar.gz".
Before my patch, if you had an archive with trailing garbage, we
got "Invalid tar magic" errors. I then stopped reading after the
second empty block without emptying the pipe, and tar said
"Broken pipe". The solution seemed obvious to me! :)

> paul
Mihai
---the text below does not belong here but I can't control it---
This e-mail (including any attachments to it) is confidential, proprietary, legally privileged, subject to copyright and is sent for the personal attention of the intended recipient only. If you have received this e-mail in error, please reply to advise us immediately, delete it and destroy any printed copies of it. You are notified that reading, disclosing, copying, distributing or taking any action in reliance on the contents of this information is strictly prohibited. No employee is authorized to conclude any binding agreement on behalf of NIVIS LLC with another party by e-mail without express written confirmation by an officer of the company. Although we have taken reasonable precautions to ensure no viruses are present in this e-mail, we cannot accept responsibility for any loss or damage arising from the viruses in this e-mail or attachments.



More information about the busybox mailing list