]> Dogcows Code - chaz/tar/blobdiff - src/list.c
Fix handling of hard link targets by -c --transform
[chaz/tar] / src / list.c
index 75837f6277217335c01768a04c29b5b0d242b5d4..98c1e396b3547cb22a5ac590bb24d03b03a9b521 100644 (file)
@@ -1,13 +1,13 @@
 /* List a tar archive, with support routines for reading a tar archive.
 
    Copyright (C) 1988, 1992, 1993, 1994, 1996, 1997, 1998, 1999, 2000,
 /* List a tar archive, with support routines for reading a tar archive.
 
    Copyright (C) 1988, 1992, 1993, 1994, 1996, 1997, 1998, 1999, 2000,
-   2001, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
+   2001, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
 
    Written by John Gilmore, on 1985-08-26.
 
    This program is free software; you can redistribute it and/or modify it
    under the terms of the GNU General Public License as published by the
 
    Written by John Gilmore, on 1985-08-26.
 
    This program is free software; you can redistribute it and/or modify it
    under the terms of the GNU General Public License as published by the
-   Free Software Foundation; either version 2, or (at your option) any later
+   Free Software Foundation; either version 3, or (at your option) any later
    version.
 
    This program is distributed in the hope that it will be useful, but
    version.
 
    This program is distributed in the hope that it will be useful, but
@@ -301,8 +301,8 @@ read_header_primitive (bool raw_extended_headers, struct tar_stat_info *info)
   size_t size, written;
   union block *next_long_name = 0;
   union block *next_long_link = 0;
   size_t size, written;
   union block *next_long_name = 0;
   union block *next_long_link = 0;
-  size_t next_long_name_blocks;
-  size_t next_long_link_blocks;
+  size_t next_long_name_blocks = 0;
+  size_t next_long_link_blocks = 0;
 
   while (1)
     {
 
   while (1)
     {
@@ -472,11 +472,11 @@ read_header (bool raw_extended_headers)
 static char *
 decode_xform (char *file_name, void *data)
 {
 static char *
 decode_xform (char *file_name, void *data)
 {
-  xform_type type = *(xform_type*)data;
+  int type = *(int*)data;
 
   switch (type)
     {
 
   switch (type)
     {
-    case xform_symlink:
+    case XFORM_SYMLINK:
       /* FIXME: It is not quite clear how and to which extent are the symbolic
         links subject to filename transformation.  In the absence of another
         solution, symbolic links are exempt from component stripping and
       /* FIXME: It is not quite clear how and to which extent are the symbolic
         links subject to filename transformation.  In the absence of another
         solution, symbolic links are exempt from component stripping and
@@ -484,11 +484,11 @@ decode_xform (char *file_name, void *data)
         proper. */ 
       return file_name;
       
         proper. */ 
       return file_name;
       
-    case xform_link:
+    case XFORM_LINK:
       file_name = safer_name_suffix (file_name, true, absolute_names_option);
       break;
       
       file_name = safer_name_suffix (file_name, true, absolute_names_option);
       break;
       
-    case xform_regfile:
+    case XFORM_REGFILE:
       file_name = safer_name_suffix (file_name, false, absolute_names_option);
       break;
     }
       file_name = safer_name_suffix (file_name, false, absolute_names_option);
       break;
     }
@@ -505,9 +505,9 @@ decode_xform (char *file_name, void *data)
 }
 
 bool
 }
 
 bool
-transform_member_name (char **pinput, xform_type type)
+transform_member_name (char **pinput, int type)
 {
 {
-  return transform_name_fp (pinput, decode_xform, &type);
+  return transform_name_fp (pinput, type, decode_xform, &type);
 }
 
 #define ISOCTAL(c) ((c)>='0'&&(c)<='7')
 }
 
 #define ISOCTAL(c) ((c)>='0'&&(c)<='7')
@@ -628,7 +628,16 @@ decode_header (union block *header, struct tar_stat_info *stat_info,
        stat_info->is_dumpdir = true;
     }
 
        stat_info->is_dumpdir = true;
     }
 
-  transform_member_name (&stat_info->file_name, xform_regfile);
+  transform_member_name (&stat_info->file_name, XFORM_REGFILE);
+  switch (header->header.typeflag)
+    {
+    case SYMTYPE:
+      transform_member_name (&stat_info->link_name, XFORM_SYMLINK);
+      break;
+      
+    case LNKTYPE:
+      transform_member_name (&stat_info->link_name, XFORM_LINK);
+    }
 }
 
 /* Convert buffer at WHERE0 of size DIGS from external format to
 }
 
 /* Convert buffer at WHERE0 of size DIGS from external format to
This page took 0.02243 seconds and 4 git commands to generate.