bug-tar
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Found a bug in tar-header at "ustar" magic indicator field


From: Juha Mäkinen
Subject: Found a bug in tar-header at "ustar" magic indicator field
Date: Tue, 27 Oct 2020 12:57:27 +0200

Hello everyone,

I looked at the contents of the tar-file in hex editor.
What I noticed is that the tar header is formed incorrectly. It's supposed to
contain the "ustar" TMAGIC indicator at offset 257 followed by a null.  But, what
I get is "ustar" followed by a space (0x20).  Then at offset 263, it's
supposed to be the TVERSION version "00", but I am seeing a space (0x20) and then a
null (0x00).

Tar creates this kind of header:
0000400  \0   u   s   t   a   r          \0   m   a   k   i   n   e   n

The correct form should be:
0000400  \0   u   s   t   a   r  \0   0   0   \0   m   a   k   i   n   e   n

In the tar source code header-file tar/tar.h this defines this as follows:
...
#define TMAGIC          "ustar" /* ustar magic 6 chars + '\0' */
#define TMAGLEN         6       /* "ustar" including '\0' */
#define TVERSION        "00"
#define TVERSLEN        2

...
In the comment it is said TMAGIC has "ustar + null", but there is only
string "ustar" set, not the null after it. Maybe this is the reason for the
incorrect header?
I
 found a build for the GNU tar from 2003 and this bug was also there, so
maybe it has circulated over 20 years...

Kind Regards,

<Juha/>

reply via email to

[Prev in Thread] Current Thread [Next in Thread]