Things like 'tar -c /tmp/*' and 'tar -cO /tmp/*' where the output
authorEric Andersen <andersen@codepoet.org>
Tue, 18 Dec 2001 00:57:55 +0000 (00:57 -0000)
committerEric Andersen <andersen@codepoet.org>
Tue, 18 Dec 2001 00:57:55 +0000 (00:57 -0000)
filename was not explicitly specified were segfaulting.
 -Erik

archival/tar.c

index 5f3f567840939d16d0cab1a9921129b35ac2bc4d..9792f6b9d72a7b04afe25391a434404142f67986 100644 (file)
@@ -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("./");