diff options
-rw-r--r-- | archival/tar.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/archival/tar.c b/archival/tar.c index 4e763a404..9ef616b92 100644 --- a/archival/tar.c +++ b/archival/tar.c | |||
@@ -462,11 +462,6 @@ static inline int writeTarFile(const int tar_fd, const int verboseFlag, | |||
462 | 462 | ||
463 | tbInfo.hlInfoHead = NULL; | 463 | tbInfo.hlInfoHead = NULL; |
464 | 464 | ||
465 | /* Make sure there is at least one file to tar up. */ | ||
466 | if (include == NULL) { | ||
467 | bb_error_msg_and_die("Cowardly refusing to create an empty archive"); | ||
468 | } | ||
469 | |||
470 | fchmod(tar_fd, 0644); | 465 | fchmod(tar_fd, 0644); |
471 | tbInfo.tarFd = tar_fd; | 466 | tbInfo.tarFd = tar_fd; |
472 | tbInfo.verboseFlag = verboseFlag; | 467 | tbInfo.verboseFlag = verboseFlag; |
@@ -748,6 +743,10 @@ int tar_main(int argc, char **argv) | |||
748 | 743 | ||
749 | #ifdef CONFIG_FEATURE_TAR_CREATE | 744 | #ifdef CONFIG_FEATURE_TAR_CREATE |
750 | if (ctx_flag == CTX_CREATE) { | 745 | if (ctx_flag == CTX_CREATE) { |
746 | /* Make sure there is at least one file to tar up. */ | ||
747 | if (tar_handle->accept == NULL) { | ||
748 | bb_error_msg_and_die("Cowardly refusing to create an empty archive"); | ||
749 | } | ||
751 | tar_stream = stdout; | 750 | tar_stream = stdout; |
752 | flags = O_WRONLY | O_CREAT | O_EXCL; | 751 | flags = O_WRONLY | O_CREAT | O_EXCL; |
753 | unlink(tar_filename); | 752 | unlink(tar_filename); |