[PATCH v4 5/8] tar: replace execlp call with BB_EXECVP, disable xz compression when applets are prefered
Nadav Tasher
tashernadav at gmail.com
Mon Jan 27 23:04:18 UTC 2025
Use BB_EXECVP for better consistency with other applets.
Allows for more control over exactly which compressor
is used.
The xz compressor is disabled when applets are prefered,
since the xz applet does not support compression.
Signed-off-by: Nadav Tasher <tashernadav at gmail.com>
---
archival/tar.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/archival/tar.c b/archival/tar.c
index d6ca6c1e0..bc46574d5 100644
--- a/archival/tar.c
+++ b/archival/tar.c
@@ -575,6 +575,7 @@ static void NOINLINE vfork_compressor(int tar_fd, const char *gzip)
// On Linux, vfork never unpauses parent early, although standard
// allows for that. Do we want to waste bytes checking for it?
# define WAIT_FOR_CHILD 0
+ const char* gzip_argv[] = { gzip, "-f", NULL };
volatile int vfork_exec_errno = 0;
struct fd_pair data;
# if WAIT_FOR_CHILD
@@ -614,11 +615,17 @@ static void NOINLINE vfork_compressor(int tar_fd, const char *gzip)
xmove_fd(tfd, 1);
/* exec gzip/bzip2/... program */
- //BB_EXECLP(gzip, gzip, "-f", (char *)0); - WRONG for "xz",
+
+# if ENABLE_FEATURE_PREFER_APPLETS
// if xz is an enabled applet, it'll be a version which
// can only decompress. We do need to execute external
// program, not applet.
- execlp(gzip, gzip, "-f", (char *)0);
+ if (strncmp(gzip, "xz", 2))
+ _exit_FAILURE();
+# endif
+
+ // This works for all other compressions
+ BB_EXECVP(gzip, gzip_argv);
vfork_exec_errno = errno;
_exit_FAILURE();
--
2.43.0
More information about the busybox
mailing list