summaryrefslogtreecommitdiff
path: root/archival/tar.c
diff options
context:
space:
mode:
authorEric Andersen2001-12-18 00:57:55 +0000
committerEric Andersen2001-12-18 00:57:55 +0000
commitf3f9062ecfb6893ca55094861c0a5e9f5ddba607 (patch)
tree80499a5e2bc648aae1753261221f99ca0ef88ab3 /archival/tar.c
parent730f826f25717c5db835ef738d4782e97b7b4720 (diff)
downloadbusybox-f3f9062ecfb6893ca55094861c0a5e9f5ddba607.zip
busybox-f3f9062ecfb6893ca55094861c0a5e9f5ddba607.tar.gz
Things like 'tar -c /tmp/*' and 'tar -cO /tmp/*' where the output
filename was not explicitly specified were segfaulting. -Erik
Diffstat (limited to 'archival/tar.c')
-rw-r--r--archival/tar.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/archival/tar.c b/archival/tar.c
index 5f3f567..9792f6b 100644
--- a/archival/tar.c
+++ b/archival/tar.c
@@ -459,7 +459,7 @@ static int writeTarFile(const char* tarName, int verboseFlag, char **argv,
error_msg_and_die("Cowardly refusing to create an empty archive");
/* Open the tar file for writing. */
- if (!strcmp(tarName, "-"))
+ if (tarName == NULL || !strcmp(tarName, "-"))
tbInfo.tarFd = fileno(stdout);
else
tbInfo.tarFd = open (tarName, O_WRONLY | O_CREAT | O_TRUNC, 0644);
@@ -694,6 +694,10 @@ int tar_main(int argc, char **argv)
optind++;
}
+ if (src_filename == NULL) {
+ extract_function |= extract_to_stdout;
+ }
+
if (extract_function & (extract_list | extract_all_to_fs)) {
if (dst_prefix == NULL) {
dst_prefix = xstrdup("./");