diff options
author | Glenn L McGrath | 2003-11-20 09:06:10 +0000 |
---|---|---|
committer | Glenn L McGrath | 2003-11-20 09:06:10 +0000 |
commit | ba49651de96fb8891b4627f85b068cb91232f1c8 (patch) | |
tree | 95ddcef5f2fc0c4e6ade827c9031a827a06ef46f /archival/tar.c | |
parent | 90c9df93f3fa9fb9c6b576c92c19bbe36bdc6e52 (diff) | |
download | busybox-ba49651de96fb8891b4627f85b068cb91232f1c8.zip busybox-ba49651de96fb8891b4627f85b068cb91232f1c8.tar.gz |
Check there are files to add the archive before removing a specified
tar file.
Diffstat (limited to 'archival/tar.c')
-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 4e763a4..9ef616b 100644 --- a/archival/tar.c +++ b/archival/tar.c @@ -462,11 +462,6 @@ static inline int writeTarFile(const int tar_fd, const int verboseFlag, tbInfo.hlInfoHead = NULL; - /* Make sure there is at least one file to tar up. */ - if (include == NULL) { - bb_error_msg_and_die("Cowardly refusing to create an empty archive"); - } - fchmod(tar_fd, 0644); tbInfo.tarFd = tar_fd; tbInfo.verboseFlag = verboseFlag; @@ -748,6 +743,10 @@ int tar_main(int argc, char **argv) #ifdef CONFIG_FEATURE_TAR_CREATE if (ctx_flag == CTX_CREATE) { + /* Make sure there is at least one file to tar up. */ + if (tar_handle->accept == NULL) { + bb_error_msg_and_die("Cowardly refusing to create an empty archive"); + } tar_stream = stdout; flags = O_WRONLY | O_CREAT | O_EXCL; unlink(tar_filename); |