diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2008-04-23 07:22:31 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2008-04-23 07:22:31 +0000 |
commit | 765c1c3c31493787b9cb53cc80574734e42a8844 (patch) | |
tree | e60dcd43cd43e6a42196f3df14ed475771aece41 | |
parent | 71e3ab327a155b513f612e328fc43e6b334fccc2 (diff) | |
download | busybox-w32-765c1c3c31493787b9cb53cc80574734e42a8844.tar.gz busybox-w32-765c1c3c31493787b9cb53cc80574734e42a8844.tar.bz2 busybox-w32-765c1c3c31493787b9cb53cc80574734e42a8844.zip |
getopt32: fix "tar x" case; fix memory leak
-rw-r--r-- | libbb/getopt32.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/libbb/getopt32.c b/libbb/getopt32.c index 913a009b0..4b5a7d208 100644 --- a/libbb/getopt32.c +++ b/libbb/getopt32.c | |||
@@ -494,7 +494,7 @@ getopt32(char **argv, const char *applet_opts, ...) | |||
494 | va_end(p); | 494 | va_end(p); |
495 | 495 | ||
496 | if (spec_flgs & FIRST_ARGV_IS_OPT) { | 496 | if (spec_flgs & FIRST_ARGV_IS_OPT) { |
497 | if (argv[1] && argv[1][0] != '-' && argv[1][1] != '\0') { | 497 | if (argv[1] && argv[1][0] != '-' && argv[1][0] != '\0') { |
498 | #if DONT_USE_PRINTF | 498 | #if DONT_USE_PRINTF |
499 | char *pp = alloca(strlen(argv[1]) + 2); | 499 | char *pp = alloca(strlen(argv[1]) + 2); |
500 | *pp = '-'; | 500 | *pp = '-'; |
@@ -502,8 +502,7 @@ getopt32(char **argv, const char *applet_opts, ...) | |||
502 | argv[1] = pp; | 502 | argv[1] = pp; |
503 | #else | 503 | #else |
504 | argv[1] = xasprintf("-%s", argv[1]); | 504 | argv[1] = xasprintf("-%s", argv[1]); |
505 | if (ENABLE_FEATURE_CLEAN_UP) | 505 | spec_flgs |= FREE_FIRST_ARGV_IS_OPT; |
506 | spec_flgs |= FREE_FIRST_ARGV_IS_OPT; | ||
507 | #endif | 506 | #endif |
508 | } | 507 | } |
509 | } | 508 | } |
@@ -586,10 +585,9 @@ getopt32(char **argv, const char *applet_opts, ...) | |||
586 | } | 585 | } |
587 | } | 586 | } |
588 | 587 | ||
589 | #if ENABLE_FEATURE_CLEAN_UP | ||
590 | if (spec_flgs & FREE_FIRST_ARGV_IS_OPT) | 588 | if (spec_flgs & FREE_FIRST_ARGV_IS_OPT) |
591 | free(argv[1]); | 589 | free(argv[1]); |
592 | #endif | 590 | |
593 | /* check depending requires for given options */ | 591 | /* check depending requires for given options */ |
594 | for (on_off = complementary; on_off->opt_char; on_off++) { | 592 | for (on_off = complementary; on_off->opt_char; on_off++) { |
595 | if (on_off->requires && (flags & on_off->switch_on) && | 593 | if (on_off->requires && (flags & on_off->switch_on) && |