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.
This commit is contained in:
Glenn L McGrath 2003-01-28 01:45:48 +00:00
parent a99534354a
commit 21110a0aa2
3 changed files with 31 additions and 19 deletions

View File

@ -182,26 +182,29 @@ config CONFIG_FEATURE_TAR_GZIP
help help
Please submit a patch to add help text for this item. Please submit a patch to add help text for this item.
config CONFIG_FEATURE_TAR_OLD_FORMAT config CONFIG_FEATURE_TAR_OLDGNU_COMPATABILITY
bool " Enable support for old tar header format" bool " Enable support for old tar header format"
default n default N
depends on CONFIG_TAR depends on CONFIG_TAR
help help
Please submit a patch to add help text for this item. This option is required to unpack archives created with
in the old GNU format, help to kill this old format by
repacking your ancient archives with the new format.
config CONFIG_FEATURE_GNUTAR_LONG_FILENAME config CONFIG_FEATURE_TAR_GNU_EXTENSIONS
bool " Enable support for GNU long filenames" bool " Enable support for some GNU tar extensions"
default y default y
depends on CONFIG_TAR depends on CONFIG_TAR
help help
Please submit a patch to add help text for this item. With this option usybox supports the GNU long filename
and linkanmes.
config CONFIG_FEATURE_UNARCHIVE_TAPE config CONFIG_FEATURE_UNARCHIVE_TAPE
bool " Enable tape drive support" bool " Enable tape drive support"
default n default n
depends on CONFIG_TAR || CONFIG_CPIO depends on CONFIG_TAR || CONFIG_CPIO
help help
Please submit a patch to add help text for this item. I dont think this is needed anymore.
config CONFIG_UNCOMPRESS config CONFIG_UNCOMPRESS
bool "uncompress" bool "uncompress"

View File

@ -84,6 +84,8 @@ extern void data_extract_all(archive_handle_t *archive_handle)
perror_msg("Cannot create node %s", file_header->name); perror_msg("Cannot create node %s", file_header->name);
} }
break; break;
default:
error_msg_and_die("Unrecognised file type");
} }
chmod(file_header->name, file_header->mode); chmod(file_header->name, file_header->mode);

View File

@ -20,7 +20,7 @@
#include "unarchive.h" #include "unarchive.h"
#include "libbb.h" #include "libbb.h"
#ifdef CONFIG_FEATURE_GNUTAR_LONG_FILENAME #ifdef CONFIG_FEATURE_TAR_GNU_EXTENSIONS
static char *longname = NULL; static char *longname = NULL;
static char *linkname = NULL; static char *linkname = NULL;
#endif #endif
@ -72,7 +72,7 @@ extern char get_header_tar(archive_handle_t *archive_handle)
* 0's are for the old tar format * 0's are for the old tar format
*/ */
if (strncmp(tar.formated.magic, "ustar", 5) != 0) { 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) if (strncmp(tar.formated.magic, "\0\0\0\0\0", 5) != 0)
#endif #endif
error_msg_and_die("Invalid tar magic"); error_msg_and_die("Invalid tar magic");
@ -90,7 +90,7 @@ extern char get_header_tar(archive_handle_t *archive_handle)
return(EXIT_FAILURE); return(EXIT_FAILURE);
} }
#ifdef CONFIG_FEATURE_GNUTAR_LONG_FILENAME #ifdef CONFIG_FEATURE_TAR_GNU_EXTENSIONS
if (longname) { if (longname) {
file_header->name = longname; file_header->name = longname;
longname = NULL; longname = NULL;
@ -120,33 +120,34 @@ extern char get_header_tar(archive_handle_t *archive_handle)
file_header->device = (dev_t) ((strtol(tar.formated.devmajor, NULL, 8) << 8) + file_header->device = (dev_t) ((strtol(tar.formated.devmajor, NULL, 8) << 8) +
strtol(tar.formated.devminor, NULL, 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 */ /* Fix mode, used by the old format */
switch (tar.formated.typeflag) { switch (tar.formated.typeflag) {
# ifdef CONFIG_FEATURE_TAR_OLD_FORMAT # ifdef CONFIG_FEATURE_TAR_OLDGNU_COMPATABILITY
case 0: case 0:
case '0':
file_header->mode |= S_IFREG; file_header->mode |= S_IFREG;
break; break;
case 1: case '1':
error_msg("Internal hard link not supported"); error_msg("Internal hard link not supported");
break; break;
case 2: case '2':
file_header->mode |= S_IFLNK; file_header->mode |= S_IFLNK;
break; break;
case 3: case '3':
file_header->mode |= S_IFCHR; file_header->mode |= S_IFCHR;
break; break;
case 4: case '4':
file_header->mode |= S_IFBLK; file_header->mode |= S_IFBLK;
break; break;
case 5: case '5':
file_header->mode |= S_IFDIR; file_header->mode |= S_IFDIR;
break; break;
case 6: case '6':
file_header->mode |= S_IFIFO; file_header->mode |= S_IFIFO;
break; break;
# endif # endif
# ifdef CONFIG_FEATURE_GNUTAR_LONG_FILENAME # ifdef CONFIG_FEATURE_TAR_GNU_EXTENSIONS
case 'L': { case 'L': {
longname = xmalloc(file_header->size + 1); longname = xmalloc(file_header->size + 1);
archive_xread_all(archive_handle, longname, file_header->size); archive_xread_all(archive_handle, longname, file_header->size);
@ -164,6 +165,12 @@ extern char get_header_tar(archive_handle_t *archive_handle)
file_header->name = linkname; file_header->name = linkname;
return(get_header_tar(archive_handle)); 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
} }
#endif #endif