aboutsummaryrefslogtreecommitdiff
path: root/contrib/tar
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/tar')
-rw-r--r--contrib/tar/src/common.h3
-rw-r--r--contrib/tar/src/extract.c8
-rw-r--r--contrib/tar/src/tar.c8
3 files changed, 18 insertions, 1 deletions
diff --git a/contrib/tar/src/common.h b/contrib/tar/src/common.h
index 40e0ab61d78f..ee2548e7d37e 100644
--- a/contrib/tar/src/common.h
+++ b/contrib/tar/src/common.h
@@ -124,6 +124,9 @@ GLOBAL size_t record_size;
/* Boolean value. */
GLOBAL int absolute_names_option;
+/* Allow GNUTYPE_NAMES type? */
+GLOBAL bool allow_name_mangling_option;
+
/* This variable tells how to interpret newer_mtime_option, below. If zero,
files get archived if their mtime is not less than newer_mtime_option.
If nonzero, files get archived if *either* their ctime or mtime is not less
diff --git a/contrib/tar/src/extract.c b/contrib/tar/src/extract.c
index 3032da06ceb3..81010a79c1c7 100644
--- a/contrib/tar/src/extract.c
+++ b/contrib/tar/src/extract.c
@@ -1219,7 +1219,13 @@ extract_archive (void)
break;
case GNUTYPE_NAMES:
- extract_mangle ();
+ if (allow_name_mangling_option)
+ extract_mangle ();
+ else {
+ ERROR ((0, 0, _("GNUTYPE_NAMES mangling ignored")));
+ if (backup_option)
+ undo_last_backup ();
+ }
break;
case GNUTYPE_MULTIVOL:
diff --git a/contrib/tar/src/tar.c b/contrib/tar/src/tar.c
index 7d872faf11a3..27ac28e35609 100644
--- a/contrib/tar/src/tar.c
+++ b/contrib/tar/src/tar.c
@@ -129,6 +129,7 @@ confirm (const char *message_action, const char *message_name)
enum
{
ANCHORED_OPTION = CHAR_MAX + 1,
+ ALLOW_NAME_MANGLING_OPTION,
BACKUP_OPTION,
DELETE_OPTION,
EXCLUDE_OPTION,
@@ -178,6 +179,7 @@ static struct option long_options[] =
{"absolute-names", no_argument, 0, 'P'},
{"absolute-paths", no_argument, 0, OBSOLETE_ABSOLUTE_NAMES},
{"after-date", required_argument, 0, 'N'},
+ {"allow-name-mangling", no_argument, 0, ALLOW_NAME_MANGLING_OPTION},
{"anchored", no_argument, 0, ANCHORED_OPTION},
{"append", no_argument, 0, 'r'},
{"atime-preserve", no_argument, &atime_preserve_option, 1},
@@ -392,6 +394,8 @@ Archive format selection:\n\
PATTERN at list/extract time, a globbing PATTERN\n\
-o, --old-archive, --portability write a V7 format archive\n\
--posix write a POSIX format archive\n\
+ --allow-name-mangling allow GNUTYPE_NAMES mangling --\n\
+ considered dangerous\n\
-j, -y, --bzip, --bzip2, --bunzip2 filter the archive through bzip2\n\
-z, --gzip, --ungzip filter the archive through gzip\n\
-Z, --compress, --uncompress filter the archive through compress\n\
@@ -901,6 +905,10 @@ decode_options (int argc, char **argv)
set_use_compress_program_option ("compress");
break;
+ case ALLOW_NAME_MANGLING_OPTION:
+ allow_name_mangling_option = true;
+ break;
+
case OBSOLETE_VERSION_CONTROL:
WARN ((0, 0, _("Obsolete option name replaced by --backup")));
/* Fall through. */