[BusyBox-cvs] busybox/archival/libunarchive get_header_tar.c, 1.30, 1.31

Glenn McGrath bug1 at busybox.net
Tue Feb 17 11:55:08 UTC 2004


Update of /var/cvs/busybox/archival/libunarchive
In directory nail:/tmp/cvs-serv27259/archival/libunarchive

Modified Files:
	get_header_tar.c 
Log Message:
Dont strip trailing '/' until _after_ i test to set if its there !


Index: get_header_tar.c
===================================================================
RCS file: /var/cvs/busybox/archival/libunarchive/get_header_tar.c,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -d -r1.30 -r1.31
--- get_header_tar.c	27 Nov 2003 00:01:43 -0000	1.30
+++ get_header_tar.c	17 Feb 2004 11:55:06 -0000	1.31
@@ -12,6 +12,10 @@
  *  You should have received a copy of the GNU General Public License
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ *  FIXME: Better checking required in oldcompatability mode, 
+ *  the file db.1.85.tar.gz from sleepycat.com has trailing garbage
+ *  GNU tar can handle it, busybox tar reports invalid tar header. 
  */
 
 #include <stdio.h>
@@ -106,14 +110,6 @@
 		file_header->name = concat_path_file(tar.formated.prefix, tar.formated.name);
 	}
 
-	{	/* Strip trailing '/' in directories */
-		char *tmp = last_char_is(file_header->name, '/');
-		if (tmp) {
-			*tmp = '\0';
-		}
-	}
-
-
 	file_header->mode = strtol(tar.formated.mode, NULL, 8);
 	file_header->uid = strtol(tar.formated.uid, NULL, 8);
 	file_header->gid = strtol(tar.formated.gid, NULL, 8);
@@ -126,12 +122,14 @@
 
 	/* Fix mode, used by the old format */
 	switch (tar.formated.typeflag) {
-# ifdef CONFIG_FEATURE_TAR_OLDGNU_COMPATABILITY
+#ifdef CONFIG_FEATURE_TAR_OLDGNU_COMPATABILITY
 	case 0:
 	case '0':
 		if (last_char_is(file_header->name, '/')) {
+			printf("directory\n");
 			file_header->mode |= S_IFDIR;
 		} else {
+			printf("regular file\n");
 			file_header->mode |= S_IFREG;
 		}
 		break;
@@ -150,12 +148,12 @@
 	case '6':
 		file_header->mode |= S_IFIFO;
 		break;
-# endif
+#endif
 	/* hard links are detected as regular files with 0 size and a link name */
 	case '1':
 		file_header->mode &= (S_IFREG | 07777);
 		break;
-# ifdef CONFIG_FEATURE_TAR_GNU_EXTENSIONS
+#ifdef CONFIG_FEATURE_TAR_GNU_EXTENSIONS
 	case 'L': {
 			longname = xmalloc(file_header->size + 1);
 			archive_xread_all(archive_handle, longname, file_header->size);
@@ -179,7 +177,14 @@
 	case 'S':
 	case 'V':
 		bb_error_msg("Ignoring GNU extension type %c", tar.formated.typeflag);
-# endif
+#endif
+	}
+	{	/* Strip trailing '/' in directories */
+		/* Must be done after mode is set as '/' is used to check if its a directory */
+		char *tmp = last_char_is(file_header->name, '/');
+		if (tmp) {
+			*tmp = '\0';
+		}
 	}
 
 	if (archive_handle->filter(archive_handle) == EXIT_SUCCESS) {




More information about the busybox-cvs mailing list