diff options
author | Eric Andersen | 2000-05-30 19:05:57 +0000 |
---|---|---|
committer | Eric Andersen | 2000-05-30 19:05:57 +0000 |
commit | 108a44345c7ca94199ab95f358312126b255f190 (patch) | |
tree | d286bf96bf33bf933fb7d0a0a6630a1f220431ef /tar.c | |
parent | e511e7c116d1a72ca9cfa5871d10bb5694a43d70 (diff) | |
download | busybox-108a44345c7ca94199ab95f358312126b255f190.zip busybox-108a44345c7ca94199ab95f358312126b255f190.tar.gz |
Fixed tar option parsing segfault, and make "tar xv" and "tar -xv"
both work (i.e. it works with or w/o the "-").
-Erik
Diffstat (limited to 'tar.c')
-rw-r--r-- | tar.c | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -173,7 +173,7 @@ extern int tar_main(int argc, char **argv) #if defined BB_FEATURE_TAR_EXCLUDE int excludeListSize=0; #endif - const char *tarName=NULL; + const char *tarName="-"; int listFlag = FALSE; int extractFlag = FALSE; int createFlag = FALSE; @@ -187,13 +187,13 @@ extern int tar_main(int argc, char **argv) /* Parse any options */ while (--argc > 0 && strspn(*(++argv), "-cxt") >0 ) { stopIt=FALSE; - while (stopIt==FALSE && *(++(*argv))) { + while (stopIt==FALSE && *argv && **argv) { switch (**argv) { case 'f': if (--argc == 0) { fatalError( "Option requires an argument: No file specified\n"); } - if (tarName != NULL) + if (*tarName != '-') fatalError( "Only one 'f' option allowed\n"); tarName = *(++argv); if (tarName == NULL) @@ -252,6 +252,7 @@ extern int tar_main(int argc, char **argv) fatalError( "Unknown tar flag '%c'\n" "Try `tar --help' for more information\n", **argv); } + ++(*argv); } } |