[BusyBox-cvs] busybox/archival/libunarchive data_extract_all.c,1.7,1.8 get_header_tar.c,1.15,1.16

Glenn McGrath bug1 at busybox.net
Tue Jan 28 01:45:52 UTC 2003


Update of /var/cvs/busybox/archival/libunarchive
In directory winder:/tmp/cvs-serv10487/archival/libunarchive

Modified Files:
	data_extract_all.c get_header_tar.c 
Log Message:
Fix long standing bug with old gnu tar files, add a check so tar will
complain "unknown file type" if it tries to extract an oldgnu tar file 
and TAR_FEATURE_OLDGNU_COMPATABILITY sint defined.
Print a warning if unisupported gnu extensions are encountered.


Index: data_extract_all.c
===================================================================
RCS file: /var/cvs/busybox/archival/libunarchive/data_extract_all.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- data_extract_all.c	10 Dec 2002 00:17:21 -0000	1.7
+++ data_extract_all.c	28 Jan 2003 01:45:48 -0000	1.8
@@ -84,6 +84,8 @@
 				perror_msg("Cannot create node %s", file_header->name);
 			}
 			break;
+		default:
+			error_msg_and_die("Unrecognised file type");
 	}
 
 	chmod(file_header->name, file_header->mode);

Index: get_header_tar.c
===================================================================
RCS file: /var/cvs/busybox/archival/libunarchive/get_header_tar.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- get_header_tar.c	8 Dec 2002 00:54:31 -0000	1.15
+++ get_header_tar.c	28 Jan 2003 01:45:48 -0000	1.16
@@ -20,7 +20,7 @@
 #include "unarchive.h"
 #include "libbb.h"
 
-#ifdef CONFIG_FEATURE_GNUTAR_LONG_FILENAME
+#ifdef CONFIG_FEATURE_TAR_GNU_EXTENSIONS
 static char *longname = NULL;
 static char *linkname = NULL;
 #endif
@@ -72,7 +72,7 @@
 	 * 0's are for the old tar format
 	 */
 	if (strncmp(tar.formated.magic, "ustar", 5) != 0) {
-#ifdef CONFIG_FEATURE_TAR_OLD_FORMAT
+#ifdef CONFIG_FEATURE_TAR_OLDGNU_COMPATABILITY
 		if (strncmp(tar.formated.magic, "\0\0\0\0\0", 5) != 0)
 #endif
 			error_msg_and_die("Invalid tar magic");
@@ -90,7 +90,7 @@
 		return(EXIT_FAILURE);
 	}
 
-#ifdef CONFIG_FEATURE_GNUTAR_LONG_FILENAME
+#ifdef CONFIG_FEATURE_TAR_GNU_EXTENSIONS
 	if (longname) {
 		file_header->name = longname;
 		longname = NULL;
@@ -120,33 +120,34 @@
 	file_header->device = (dev_t) ((strtol(tar.formated.devmajor, NULL, 8) << 8) +
 				 strtol(tar.formated.devminor, NULL, 8));
 
-#if defined CONFIG_FEATURE_TAR_OLD_FORMAT || defined CONFIG_FEATURE_GNUTAR_LONG_FILENAME
+#if defined CONFIG_FEATURE_TAR_OLDGNU_COMPATABILITY || defined CONFIG_FEATURE_TAR_GNU_EXTENSIONS
 	/* Fix mode, used by the old format */
 	switch (tar.formated.typeflag) {
-# ifdef CONFIG_FEATURE_TAR_OLD_FORMAT
+# ifdef CONFIG_FEATURE_TAR_OLDGNU_COMPATABILITY
 	case 0:
+	case '0':
 		file_header->mode |= S_IFREG;
 		break;
-	case 1:
+	case '1':
 		error_msg("Internal hard link not supported");
 		break;
-	case 2:
+	case '2':
 		file_header->mode |= S_IFLNK;
 		break;
-	case 3:
+	case '3':
 		file_header->mode |= S_IFCHR;
 		break;
-	case 4:
+	case '4':
 		file_header->mode |= S_IFBLK;
 		break;
-	case 5:
+	case '5':
 		file_header->mode |= S_IFDIR;
 		break;
-	case 6:
+	case '6':
 		file_header->mode |= S_IFIFO;
 		break;
 # endif
-# ifdef CONFIG_FEATURE_GNUTAR_LONG_FILENAME
+# ifdef CONFIG_FEATURE_TAR_GNU_EXTENSIONS
 	case 'L': {
 			longname = xmalloc(file_header->size + 1);
 			archive_xread_all(archive_handle, longname, file_header->size);
@@ -164,6 +165,12 @@
 			file_header->name = linkname;
 			return(get_header_tar(archive_handle));
 		}
+	case 'D':
+	case 'M':
+	case 'N':
+	case 'S':
+	case 'V':
+		error_msg("Ignoring GNU extension type %c", tar.formated.typeflag);
 # endif
 	}
 #endif




More information about the busybox-cvs mailing list