aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2017-08-22 16:33:06 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2017-08-23 12:19:44 +0200
commit6bafcfb67a30dde668cceeab7669082fbcf5a489 (patch)
tree44c9561d153f5d340bc466153a9bf52b94f997ab
parent3505e38bd1e5714fa1203e6752c573861aab8521 (diff)
downloadbusybox-w32-6bafcfb67a30dde668cceeab7669082fbcf5a489.tar.gz
busybox-w32-6bafcfb67a30dde668cceeab7669082fbcf5a489.tar.bz2
busybox-w32-6bafcfb67a30dde668cceeab7669082fbcf5a489.zip
tar: fix handling of first argument without '-'
The following no longer works as expected: $ ./busybox tar xfz test.tgz tar: can't open 'z': No such file or directory Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--archival/tar.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/archival/tar.c b/archival/tar.c
index 9a5bcc7fe..6cf3508ec 100644
--- a/archival/tar.c
+++ b/archival/tar.c
@@ -953,9 +953,6 @@ int tar_main(int argc UNUSED_PARAM, char **argv)
953 if (getuid() != 0) 953 if (getuid() != 0)
954 tar_handle->ah_flags |= ARCHIVE_DONT_RESTORE_PERM; 954 tar_handle->ah_flags |= ARCHIVE_DONT_RESTORE_PERM;
955 955
956 /* Prepend '-' to the first argument if required */
957 if (argv[1] && argv[1][0] != '-' && argv[1][0] != '\0')
958 argv[1] = xasprintf("-%s", argv[1]);
959#if ENABLE_DESKTOP 956#if ENABLE_DESKTOP
960 /* Lie to buildroot when it starts asking stupid questions. */ 957 /* Lie to buildroot when it starts asking stupid questions. */
961 if (argv[1] && strcmp(argv[1], "--version") == 0) { 958 if (argv[1] && strcmp(argv[1], "--version") == 0) {
@@ -992,6 +989,9 @@ int tar_main(int argc UNUSED_PARAM, char **argv)
992 } 989 }
993 } 990 }
994#endif 991#endif
992 /* Prepend '-' to the first argument if required */
993 if (argv[1] && argv[1][0] != '-' && argv[1][0] != '\0')
994 argv[1] = xasprintf("-%s", argv[1]);
995 opt = GETOPT32(argv, "^" 995 opt = GETOPT32(argv, "^"
996 "txC:f:Oopvk" 996 "txC:f:Oopvk"
997 IF_FEATURE_TAR_CREATE( "ch" ) 997 IF_FEATURE_TAR_CREATE( "ch" )