summaryrefslogtreecommitdiff
path: root/archival/tar.c
diff options
context:
space:
mode:
authorDenis Vlasenko2007-02-04 21:30:35 +0000
committerDenis Vlasenko2007-02-04 21:30:35 +0000
commit8c0164c373da4dc4aa8e6dc679ac1b7c093dce6b (patch)
tree76d3d4aa00231c0a9b9ff6d8d0713e6f9942a3f5 /archival/tar.c
parentd909d2345158e80ec2fee188ce3ca668850c5ee9 (diff)
downloadbusybox-8c0164c373da4dc4aa8e6dc679ac1b7c093dce6b.zip
busybox-8c0164c373da4dc4aa8e6dc679ac1b7c093dce6b.tar.gz
fix tar t segfault (closes 1183)
Diffstat (limited to 'archival/tar.c')
-rw-r--r--archival/tar.c43
1 files changed, 25 insertions, 18 deletions
diff --git a/archival/tar.c b/archival/tar.c
index 8bb8459..48c4f3f 100644
--- a/archival/tar.c
+++ b/archival/tar.c
@@ -761,7 +761,9 @@ int tar_main(int argc, char **argv)
const char *tar_filename = "-";
unsigned opt;
int verboseFlag = 0;
+#if ENABLE_FEATURE_TAR_LONG_OPTIONS && ENABLE_FEATURE_TAR_FROM
llist_t *excludes = NULL;
+#endif
/* Initialise default values */
tar_handle = init_handle();
@@ -774,7 +776,9 @@ int tar_main(int argc, char **argv)
"tt:vv:" // count -t,-v
"?:" // bail out with usage instead of error return
"X::T::" // cumulative lists
+#if ENABLE_FEATURE_TAR_LONG_OPTIONS && ENABLE_FEATURE_TAR_FROM
"\xff::" // cumulative lists for --exclude
+#endif
USE_FEATURE_TAR_CREATE("c:") "t:x:" // at least one of these is reqd
USE_FEATURE_TAR_CREATE("c--tx:t--cx:x--ct") // mutually exclusive
SKIP_FEATURE_TAR_CREATE("t--x:x--t"); // mutually exclusive
@@ -789,14 +793,15 @@ int tar_main(int argc, char **argv)
USE_FEATURE_TAR_FROM( "T:X:")
USE_FEATURE_TAR_GZIP( "z" )
USE_FEATURE_TAR_COMPRESS("Z" )
- ,
- &base_dir, // -C dir
- &tar_filename, // -f filename
- USE_FEATURE_TAR_FROM(&(tar_handle->accept),) // T
- USE_FEATURE_TAR_FROM(&(tar_handle->reject),) // X
- USE_FEATURE_TAR_FROM(&excludes ,) // --exclude
- &verboseFlag, // combined count for -t and -v
- &verboseFlag // combined count for -t and -v
+ , &base_dir // -C dir
+ , &tar_filename // -f filename
+ USE_FEATURE_TAR_FROM(, &(tar_handle->accept)) // T
+ USE_FEATURE_TAR_FROM(, &(tar_handle->reject)) // X
+#if ENABLE_FEATURE_TAR_LONG_OPTIONS && ENABLE_FEATURE_TAR_FROM
+ , &excludes // --exclude
+#endif
+ , &verboseFlag // combined count for -t and -v
+ , &verboseFlag // combined count for -t and -v
);
if (verboseFlag) tar_handle->action_header = header_verbose_list;
@@ -829,17 +834,19 @@ int tar_main(int argc, char **argv)
if (opt & OPT_COMPRESS)
get_header_ptr = get_header_tar_Z;
- if (ENABLE_FEATURE_TAR_FROM) {
- tar_handle->reject = append_file_list_to_list(tar_handle->reject);
- /* Append excludes to reject */
- while (excludes) {
- llist_t *temp = excludes->link;
- excludes->link = tar_handle->reject;
- tar_handle->reject = excludes;
- excludes = temp;
- }
- tar_handle->accept = append_file_list_to_list(tar_handle->accept);
+#if ENABLE_FEATURE_TAR_FROM
+ tar_handle->reject = append_file_list_to_list(tar_handle->reject);
+#if ENABLE_FEATURE_TAR_LONG_OPTIONS
+ /* Append excludes to reject */
+ while (excludes) {
+ llist_t *next = excludes->link;
+ excludes->link = tar_handle->reject;
+ tar_handle->reject = excludes;
+ excludes = next;
}
+#endif
+ tar_handle->accept = append_file_list_to_list(tar_handle->accept);
+#endif
/* Check if we are reading from stdin */
if (argv[optind] && *argv[optind] == '-') {