Package: tar
Version: 1.23-3

I am actually not a Debian user, I am the maintainer of Python's tarfile
module. In a discussion with a Debian user about a very specific tar-related
problem I found out that the version of GNU tar shipped with Debian is patched
in order to produce longname headers for filenames longer than 99 characters
instead of 100. 100 is the maximum size of the filename field in a ustar
header. According to posix the string in this field shall be null-terminated
unless it is exactly 100 characters long, then it is allowed to fill the whole
field. A pristine GNU tar follows posix in that respect: it uses the whole
field and creates longname headers for filenames > 100.

This is the patch in question:

--- tar-1.23.orig/src/create.c
+++ tar-1.23/src/create.c
@@ -747,7 +747,7 @@
       return write_short_name (st);
     }
   else if (NAME_FIELD_SIZE - (archive_format == OLDGNU_FORMAT)
-          < strlen (st->file_name))
+          <= strlen (st->file_name))
     return write_long_name (st);
   else
     return write_short_name (st);
@@ -1399,7 +1399,7 @@
          block_ordinal = current_block_ordinal ();
          assign_string (&st->link_name, link_name);
          if (NAME_FIELD_SIZE - (archive_format == OLDGNU_FORMAT)
-             < strlen (link_name))
+             <= strlen (link_name))
            write_long_link (st);
 
          st->stat.st_size = 0;


I browsed through the history and found out that this patch was introduced back
in 2004 to work around some problems in dpkg (bug #230910). dpkg was fixed four
weeks later (bug #232025), but the patch has not been reverted up to this day.

Two things I'd like to bring forward:

1. I think that after more than six years it is time to remove this patch. In
my opinion, it is undesirable for Debian's tar being different from the original
GNU tar in such a fundamental aspect (without a proper reason).

2. The patch is of very poor quality. If removing it is not possible for
whatever reason there might be, please consider to use a nicer patch, like the
one below.

diff -ur tar-1.23.orig/src/create.c tar-1.23/src/create.c
--- tar-1.23.orig/src/create.c  2010-03-09 13:52:41.000000000 +0100
+++ tar-1.23/src/create.c       2010-09-28 10:55:36.924456156 +0200
@@ -746,8 +746,7 @@
       xheader_store ("path", st, NULL);
       return write_short_name (st);
     }
-  else if (NAME_FIELD_SIZE - (archive_format == OLDGNU_FORMAT)
-          < strlen (st->file_name))
+  else if (NAME_FIELD_SIZE - 1 < strlen (st->file_name))
     return write_long_name (st);
   else
     return write_short_name (st);
@@ -1398,8 +1397,7 @@
 
          block_ordinal = current_block_ordinal ();
          assign_string (&st->link_name, link_name);
-         if (NAME_FIELD_SIZE - (archive_format == OLDGNU_FORMAT)
-             < strlen (link_name))
+         if (NAME_FIELD_SIZE - 1 < strlen (link_name))
            write_long_link (st);
 
          st->stat.st_size = 0;


Thanks for your time.

-- 
Lars Gustäbel
l...@gustaebel.de



--
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to