aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGlenn L McGrath <bug1@ihug.co.nz>2002-11-08 07:09:42 +0000
committerGlenn L McGrath <bug1@ihug.co.nz>2002-11-08 07:09:42 +0000
commitf6bf7a03fec2ae854bdbf7a597484b7ab49a4a51 (patch)
tree58a1eafb8c61be3a3b5567e69588cb227021018d
parentb26674b2f8a300d9ec41a7a728426beb0536acd2 (diff)
downloadbusybox-f6bf7a03fec2ae854bdbf7a597484b7ab49a4a51.tar.gz
Fix reading from stdin (me), Fix tar segfault when no arguments specified (Geoffrey Lee)
-rw-r--r--archival/tar.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/archival/tar.c b/archival/tar.c
index 95ef33b74..01ec90c6f 100644
--- a/archival/tar.c
+++ b/archival/tar.c
@@ -611,6 +611,10 @@ int tar_main(int argc, char **argv)
unsigned char tar_create = FALSE;
#endif
+ if (argc < 2) {
+ show_usage();
+ }
+
/* Prepend '-' to the first argument if required */
if (argv[1][0] != '-') {
char *tmp = xmalloc(strlen(argv[1]) + 2);
@@ -619,10 +623,6 @@ int tar_main(int argc, char **argv)
argv[1] = tmp;
}
- if (argc < 2) {
- show_usage();
- }
-
/* Initialise default values */
tar_handle = init_handle();
tar_handle->flags = ARCHIVE_CREATE_LEADING_DIRS;
@@ -736,13 +736,13 @@ int tar_main(int argc, char **argv)
{
if ((tar_filename[0] == '-') && (tar_filename[1] == '\0')) {
tar_handle->src_fd = fileno(stdin);
+ tar_handle->seek = seek_by_char;
} else {
tar_handle->seek = seek_by_jump;
tar_handle->src_fd = xopen(tar_filename, O_RDONLY);
}
#ifdef CONFIG_FEATURE_TAR_GZIP
if (get_header_ptr == get_header_tar_gz) {
- tar_handle->seek = seek_by_char;
get_header_tar_gz(tar_handle);
} else
#endif /* CONFIG_FEATURE_TAR_GZIP */