bug-tar
[Top][All Lists]
Advanced

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

[Bug-tar] (no subject)


From: Stephan Springl
Subject: [Bug-tar] (no subject)
Date: Tue, 16 Aug 2016 12:30:59 +0200 (CEST)

Hi,

tar gives wrong block numbers for symlinks with long
names with the -R or --block-number option while creating
archives.  Reproduce with a symlink with a long name
pointing at another long name:

$ tar -vv -c -R -f a.tar 
dxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
block 2: lrwxrwxrwx springl/src       0 2016-08-16 12:12 
dxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
 -> 
sxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

tar -tvRf a.tar
block 0: lrwxrwxrwx springl/src       0 2016-08-16 12:12 
dxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
 -> 
sxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
block 5: ** Block of NULs **

Creating the archive, block 2 is given for the entry in the
archive which is wrong.  Reading the archive, it correctly
gives block 0.

The following patch seems to fix the problem for me:

diff --git a/src/create.c b/src/create.c
index 9164f7c..5a73f26 100644
--- a/src/create.c
+++ b/src/create.c
@@ -1876,6 +1876,7 @@ dump_file0 (struct tar_stat_info *st, char const *name, 
char const *p)
          file_removed_diag (p, top_level, readlink_diag);
          return;
        }
+      block_ordinal = current_block_ordinal ();
       transform_name (&st->link_name, XFORM_SYMLINK);
       if (NAME_FIELD_SIZE - (archive_format == OLDGNU_FORMAT)
          < strlen (st->link_name))
@@ -1884,7 +1885,6 @@ dump_file0 (struct tar_stat_info *st, char const *name, 
char const *p)
       xattrs_selinux_get (parentfd, name, st, 0);
       xattrs_xattrs_get (parentfd, name, st, 0);

-      block_ordinal = current_block_ordinal ();
       st->stat.st_size = 0; /* force 0 size on symlink */
       header = start_header (st);
       if (!header)

Regards,
Stephan



reply via email to

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