[PATCH 1/1] tar: Increase robustness of file descriptor handling
Tobias Schramm
tobleminer at gmail.com
Fri Aug 3 21:09:06 UTC 2018
Moving the destination fd first ensures it is never overwritten even
if it is fd 0.
Signed-off-by: Tobias Schramm <tobleminer at gmail.com>
---
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
More information about the busybox
mailing list