mirror of
https://git.savannah.gnu.org/git/tar.git
synced 2026-09-05 15:56:55 +00:00
Fix handling of hard link targets by -c --transform
* src/create.c (file_count_links): Transform link target before the look up. * tests/xform-h.at: New test case. * tests/Makefile.am (TESTSUITE_AT): Add xform-h.at. * tests/testsuite.at: Add xform-h.at
This commit is contained in:
+12
-5
@@ -1427,19 +1427,26 @@ file_count_links (struct tar_stat_info *st)
|
||||
if (st->stat.st_nlink > 1)
|
||||
{
|
||||
struct link *duplicate;
|
||||
struct link *lp = xmalloc (offsetof (struct link, name)
|
||||
+ strlen (st->orig_file_name) + 1);
|
||||
char *linkname = NULL;
|
||||
struct link *lp;
|
||||
|
||||
assign_string (&linkname, st->orig_file_name);
|
||||
transform_name (&linkname, XFORM_LINK);
|
||||
|
||||
lp = xmalloc (offsetof (struct link, name)
|
||||
+ strlen (linkname) + 1);
|
||||
lp->ino = st->stat.st_ino;
|
||||
lp->dev = st->stat.st_dev;
|
||||
lp->nlink = st->stat.st_nlink;
|
||||
strcpy (lp->name, st->orig_file_name);
|
||||
|
||||
strcpy (lp->name, linkname);
|
||||
free (linkname);
|
||||
|
||||
if (! ((link_table
|
||||
|| (link_table = hash_initialize (0, 0, hash_link,
|
||||
compare_links, 0)))
|
||||
&& (duplicate = hash_insert (link_table, lp))))
|
||||
xalloc_die ();
|
||||
|
||||
|
||||
if (duplicate != lp)
|
||||
abort ();
|
||||
lp->nlink--;
|
||||
|
||||
Reference in New Issue
Block a user