diff options
author | Eric Andersen <andersen@codepoet.org> | 2001-12-18 00:57:55 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2001-12-18 00:57:55 +0000 |
commit | f3f9062ecfb6893ca55094861c0a5e9f5ddba607 (patch) | |
tree | 80499a5e2bc648aae1753261221f99ca0ef88ab3 | |
parent | 730f826f25717c5db835ef738d4782e97b7b4720 (diff) | |
download | busybox-w32-f3f9062ecfb6893ca55094861c0a5e9f5ddba607.tar.gz busybox-w32-f3f9062ecfb6893ca55094861c0a5e9f5ddba607.tar.bz2 busybox-w32-f3f9062ecfb6893ca55094861c0a5e9f5ddba607.zip |
Things like 'tar -c /tmp/*' and 'tar -cO /tmp/*' where the output
filename was not explicitly specified were segfaulting.
-Erik
-rw-r--r-- | archival/tar.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/archival/tar.c b/archival/tar.c index 5f3f56784..9792f6b9d 100644 --- a/archival/tar.c +++ b/archival/tar.c | |||
@@ -459,7 +459,7 @@ static int writeTarFile(const char* tarName, int verboseFlag, char **argv, | |||
459 | error_msg_and_die("Cowardly refusing to create an empty archive"); | 459 | error_msg_and_die("Cowardly refusing to create an empty archive"); |
460 | 460 | ||
461 | /* Open the tar file for writing. */ | 461 | /* Open the tar file for writing. */ |
462 | if (!strcmp(tarName, "-")) | 462 | if (tarName == NULL || !strcmp(tarName, "-")) |
463 | tbInfo.tarFd = fileno(stdout); | 463 | tbInfo.tarFd = fileno(stdout); |
464 | else | 464 | else |
465 | tbInfo.tarFd = open (tarName, O_WRONLY | O_CREAT | O_TRUNC, 0644); | 465 | tbInfo.tarFd = open (tarName, O_WRONLY | O_CREAT | O_TRUNC, 0644); |
@@ -694,6 +694,10 @@ int tar_main(int argc, char **argv) | |||
694 | optind++; | 694 | optind++; |
695 | } | 695 | } |
696 | 696 | ||
697 | if (src_filename == NULL) { | ||
698 | extract_function |= extract_to_stdout; | ||
699 | } | ||
700 | |||
697 | if (extract_function & (extract_list | extract_all_to_fs)) { | 701 | if (extract_function & (extract_list | extract_all_to_fs)) { |
698 | if (dst_prefix == NULL) { | 702 | if (dst_prefix == NULL) { |
699 | dst_prefix = xstrdup("./"); | 703 | dst_prefix = xstrdup("./"); |