Moving the destination fd first ensures it is never overwritten even
if it is fd 0.

Signed-off-by: Tobias Schramm <[email protected]>
---
 archival/tar.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/archival/tar.c b/archival/tar.c
index ae1ccc756..94793977c 100644
--- a/archival/tar.c
+++ b/archival/tar.c
@@ -623,8 +623,8 @@ static void NOINLINE vfork_compressor(int tar_fd, const 
char *gzip)
                 * parent waits for this close to happen */
                fcntl(gzipStatusPipe.wr, F_SETFD, FD_CLOEXEC);
 #  endif
-               xmove_fd(gzipDataPipe.rd, 0);
                xmove_fd(tar_fd, 1);
+               xmove_fd(gzipDataPipe.rd, 0);
                /* exec gzip/bzip2 program/applet */
                BB_EXECLP(gzip, gzip, "-f", (char *)0);
                vfork_exec_errno = errno;
-- 
2.18.0

_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to