fix tar t segfault (closes 1183)
This commit is contained in:
@ -761,7 +761,9 @@ int tar_main(int argc, char **argv)
|
|||||||
const char *tar_filename = "-";
|
const char *tar_filename = "-";
|
||||||
unsigned opt;
|
unsigned opt;
|
||||||
int verboseFlag = 0;
|
int verboseFlag = 0;
|
||||||
|
#if ENABLE_FEATURE_TAR_LONG_OPTIONS && ENABLE_FEATURE_TAR_FROM
|
||||||
llist_t *excludes = NULL;
|
llist_t *excludes = NULL;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Initialise default values */
|
/* Initialise default values */
|
||||||
tar_handle = init_handle();
|
tar_handle = init_handle();
|
||||||
@ -774,7 +776,9 @@ int tar_main(int argc, char **argv)
|
|||||||
"tt:vv:" // count -t,-v
|
"tt:vv:" // count -t,-v
|
||||||
"?:" // bail out with usage instead of error return
|
"?:" // bail out with usage instead of error return
|
||||||
"X::T::" // cumulative lists
|
"X::T::" // cumulative lists
|
||||||
|
#if ENABLE_FEATURE_TAR_LONG_OPTIONS && ENABLE_FEATURE_TAR_FROM
|
||||||
"\xff::" // cumulative lists for --exclude
|
"\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:") "t:x:" // at least one of these is reqd
|
||||||
USE_FEATURE_TAR_CREATE("c--tx:t--cx:x--ct") // mutually exclusive
|
USE_FEATURE_TAR_CREATE("c--tx:t--cx:x--ct") // mutually exclusive
|
||||||
SKIP_FEATURE_TAR_CREATE("t--x:x--t"); // 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_FROM( "T:X:")
|
||||||
USE_FEATURE_TAR_GZIP( "z" )
|
USE_FEATURE_TAR_GZIP( "z" )
|
||||||
USE_FEATURE_TAR_COMPRESS("Z" )
|
USE_FEATURE_TAR_COMPRESS("Z" )
|
||||||
,
|
, &base_dir // -C dir
|
||||||
&base_dir, // -C dir
|
, &tar_filename // -f filename
|
||||||
&tar_filename, // -f filename
|
USE_FEATURE_TAR_FROM(, &(tar_handle->accept)) // T
|
||||||
USE_FEATURE_TAR_FROM(&(tar_handle->accept),) // T
|
USE_FEATURE_TAR_FROM(, &(tar_handle->reject)) // X
|
||||||
USE_FEATURE_TAR_FROM(&(tar_handle->reject),) // X
|
#if ENABLE_FEATURE_TAR_LONG_OPTIONS && ENABLE_FEATURE_TAR_FROM
|
||||||
USE_FEATURE_TAR_FROM(&excludes ,) // --exclude
|
, &excludes // --exclude
|
||||||
&verboseFlag, // combined count for -t and -v
|
#endif
|
||||||
&verboseFlag // combined count for -t and -v
|
, &verboseFlag // combined count for -t and -v
|
||||||
|
, &verboseFlag // combined count for -t and -v
|
||||||
);
|
);
|
||||||
|
|
||||||
if (verboseFlag) tar_handle->action_header = header_verbose_list;
|
if (verboseFlag) tar_handle->action_header = header_verbose_list;
|
||||||
@ -829,17 +834,19 @@ int tar_main(int argc, char **argv)
|
|||||||
if (opt & OPT_COMPRESS)
|
if (opt & OPT_COMPRESS)
|
||||||
get_header_ptr = get_header_tar_Z;
|
get_header_ptr = get_header_tar_Z;
|
||||||
|
|
||||||
if (ENABLE_FEATURE_TAR_FROM) {
|
#if ENABLE_FEATURE_TAR_FROM
|
||||||
tar_handle->reject = append_file_list_to_list(tar_handle->reject);
|
tar_handle->reject = append_file_list_to_list(tar_handle->reject);
|
||||||
/* Append excludes to reject */
|
#if ENABLE_FEATURE_TAR_LONG_OPTIONS
|
||||||
while (excludes) {
|
/* Append excludes to reject */
|
||||||
llist_t *temp = excludes->link;
|
while (excludes) {
|
||||||
excludes->link = tar_handle->reject;
|
llist_t *next = excludes->link;
|
||||||
tar_handle->reject = excludes;
|
excludes->link = tar_handle->reject;
|
||||||
excludes = temp;
|
tar_handle->reject = excludes;
|
||||||
}
|
excludes = next;
|
||||||
tar_handle->accept = append_file_list_to_list(tar_handle->accept);
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
tar_handle->accept = append_file_list_to_list(tar_handle->accept);
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Check if we are reading from stdin */
|
/* Check if we are reading from stdin */
|
||||||
if (argv[optind] && *argv[optind] == '-') {
|
if (argv[optind] && *argv[optind] == '-') {
|
||||||
|
Reference in New Issue
Block a user