bug-tar
[Top][All Lists]
Advanced

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

Re: [Bug-tar] GNU tar 1.22 creating USTAR not readable by other TAR impl


From: Sergey Poznyakoff
Subject: Re: [Bug-tar] GNU tar 1.22 creating USTAR not readable by other TAR implementations
Date: Sun, 20 Dec 2009 17:59:42 +0200

Hello,

Thanks a lot for your feedback.

After carefully re-reading the POSIX specs, I could find nothing
that indicated that the combination of an empty name field with
non-empty prefix is forbidden in ustar headers.  So, I believe that
the way GNU tar creates ustar archives is entirely POSIX-compliant.
In my opinion, the fact that Sun tar is unable to handle such
records rather indicates a bug in Sun's implementation. 

Nevertheless, since GNU tar supports ustar format mainly for
compatibility with older implementations, it is perhaps a good idea to
introduce a "bug-to-bug" compatibility.  As far as I can tell, the
attached patch makes GNU tar behave as its Sun counterpart in regard to
name splitting.  I'd appreciate it if you could test it with your
script.  I'm particularly interested in "Solaris can't handle TAR"
errors.  However, the plain statement is not enough to deduce the
reason for that, so please include the exact diagnostics produced
by Sun's tar in that case.

FWIW, so far I am not sure whether to enable such compatibility mode by
default, or rather make it dependent on some command line option.

Regards,
Sergey

diff --git a/src/create.c b/src/create.c
index 3add5a0..0aa00b7 100644
--- a/src/create.c
+++ b/src/create.c
@@ -602,8 +602,10 @@ split_long_name (const char *name, size_t length)
 {
   size_t i;
 
-  if (length > PREFIX_FIELD_SIZE)
+  if (length > PREFIX_FIELD_SIZE + 1)
     length = PREFIX_FIELD_SIZE + 1;
+  else if (ISSLASH (name[length - 1]))
+    length--;
   for (i = length - 1; i > 0; i--)
     if (ISSLASH (name[i]))
       break;

reply via email to

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