summaryrefslogtreecommitdiff
path: root/archival
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2007-02-04 21:30:35 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2007-02-04 21:30:35 +0000
commit8c0164c373da4dc4aa8e6dc679ac1b7c093dce6b (patch)
tree76d3d4aa00231c0a9b9ff6d8d0713e6f9942a3f5 /archival
parentd909d2345158e80ec2fee188ce3ca668850c5ee9 (diff)
downloadbusybox-w32-8c0164c373da4dc4aa8e6dc679ac1b7c093dce6b.tar.gz
busybox-w32-8c0164c373da4dc4aa8e6dc679ac1b7c093dce6b.tar.bz2
busybox-w32-8c0164c373da4dc4aa8e6dc679ac1b7c093dce6b.zip
fix tar t segfault (closes 1183)
Diffstat (limited to 'archival')
-rw-r--r--archival/tar.c43
1 files changed, 25 insertions, 18 deletions
diff --git a/archival/tar.c b/archival/tar.c
index 8bb845942..48c4f3f8c 100644
--- a/archival/tar.c
+++ b/archival/tar.c
@@ -761,7 +761,9 @@ int tar_main(int argc, char **argv)
761 const char *tar_filename = "-"; 761 const char *tar_filename = "-";
762 unsigned opt; 762 unsigned opt;
763 int verboseFlag = 0; 763 int verboseFlag = 0;
764#if ENABLE_FEATURE_TAR_LONG_OPTIONS && ENABLE_FEATURE_TAR_FROM
764 llist_t *excludes = NULL; 765 llist_t *excludes = NULL;
766#endif
765 767
766 /* Initialise default values */ 768 /* Initialise default values */
767 tar_handle = init_handle(); 769 tar_handle = init_handle();
@@ -774,7 +776,9 @@ int tar_main(int argc, char **argv)
774 "tt:vv:" // count -t,-v 776 "tt:vv:" // count -t,-v
775 "?:" // bail out with usage instead of error return 777 "?:" // bail out with usage instead of error return
776 "X::T::" // cumulative lists 778 "X::T::" // cumulative lists
779#if ENABLE_FEATURE_TAR_LONG_OPTIONS && ENABLE_FEATURE_TAR_FROM
777 "\xff::" // cumulative lists for --exclude 780 "\xff::" // cumulative lists for --exclude
781#endif
778 USE_FEATURE_TAR_CREATE("c:") "t:x:" // at least one of these is reqd 782 USE_FEATURE_TAR_CREATE("c:") "t:x:" // at least one of these is reqd
779 USE_FEATURE_TAR_CREATE("c--tx:t--cx:x--ct") // mutually exclusive 783 USE_FEATURE_TAR_CREATE("c--tx:t--cx:x--ct") // mutually exclusive
780 SKIP_FEATURE_TAR_CREATE("t--x:x--t"); // mutually exclusive 784 SKIP_FEATURE_TAR_CREATE("t--x:x--t"); // mutually exclusive
@@ -789,14 +793,15 @@ int tar_main(int argc, char **argv)
789 USE_FEATURE_TAR_FROM( "T:X:") 793 USE_FEATURE_TAR_FROM( "T:X:")
790 USE_FEATURE_TAR_GZIP( "z" ) 794 USE_FEATURE_TAR_GZIP( "z" )
791 USE_FEATURE_TAR_COMPRESS("Z" ) 795 USE_FEATURE_TAR_COMPRESS("Z" )
792 , 796 , &base_dir // -C dir
793 &base_dir, // -C dir 797 , &tar_filename // -f filename
794 &tar_filename, // -f filename 798 USE_FEATURE_TAR_FROM(, &(tar_handle->accept)) // T
795 USE_FEATURE_TAR_FROM(&(tar_handle->accept),) // T 799 USE_FEATURE_TAR_FROM(, &(tar_handle->reject)) // X
796 USE_FEATURE_TAR_FROM(&(tar_handle->reject),) // X 800#if ENABLE_FEATURE_TAR_LONG_OPTIONS && ENABLE_FEATURE_TAR_FROM
797 USE_FEATURE_TAR_FROM(&excludes ,) // --exclude 801 , &excludes // --exclude
798 &verboseFlag, // combined count for -t and -v 802#endif
799 &verboseFlag // combined count for -t and -v 803 , &verboseFlag // combined count for -t and -v
804 , &verboseFlag // combined count for -t and -v
800 ); 805 );
801 806
802 if (verboseFlag) tar_handle->action_header = header_verbose_list; 807 if (verboseFlag) tar_handle->action_header = header_verbose_list;
@@ -829,17 +834,19 @@ int tar_main(int argc, char **argv)
829 if (opt & OPT_COMPRESS) 834 if (opt & OPT_COMPRESS)
830 get_header_ptr = get_header_tar_Z; 835 get_header_ptr = get_header_tar_Z;
831 836
832 if (ENABLE_FEATURE_TAR_FROM) { 837#if ENABLE_FEATURE_TAR_FROM
833 tar_handle->reject = append_file_list_to_list(tar_handle->reject); 838 tar_handle->reject = append_file_list_to_list(tar_handle->reject);
834 /* Append excludes to reject */ 839#if ENABLE_FEATURE_TAR_LONG_OPTIONS
835 while (excludes) { 840 /* Append excludes to reject */
836 llist_t *temp = excludes->link; 841 while (excludes) {
837 excludes->link = tar_handle->reject; 842 llist_t *next = excludes->link;
838 tar_handle->reject = excludes; 843 excludes->link = tar_handle->reject;
839 excludes = temp; 844 tar_handle->reject = excludes;
840 } 845 excludes = next;
841 tar_handle->accept = append_file_list_to_list(tar_handle->accept);
842 } 846 }
847#endif
848 tar_handle->accept = append_file_list_to_list(tar_handle->accept);
849#endif
843 850
844 /* Check if we are reading from stdin */ 851 /* Check if we are reading from stdin */
845 if (argv[optind] && *argv[optind] == '-') { 852 if (argv[optind] && *argv[optind] == '-') {