diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2018-04-07 13:22:52 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2018-04-07 13:22:52 +0200 |
commit | 32c3e3a44cb6ae2b0ff949e9f60fa0405f081dc3 (patch) | |
tree | 32fa4cc8f164ea093ee4a0d45ac9128fe9bbf2f5 /networking/wget.c | |
parent | 9fe8bd8d61d8cf187ad40affb1f69fe72ae74744 (diff) | |
download | busybox-w32-32c3e3a44cb6ae2b0ff949e9f60fa0405f081dc3.tar.gz busybox-w32-32c3e3a44cb6ae2b0ff949e9f60fa0405f081dc3.tar.bz2 busybox-w32-32c3e3a44cb6ae2b0ff949e9f60fa0405f081dc3.zip |
wget,ftpd: shorten and reuse strings
function old new delta
wget_main 2382 2386 +4
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/0 up/down: 4/0) Total: 4 bytes
text data bss dec hex filename
934228 477 7296 942001 e5fb1 busybox_old
934202 477 7296 941975 e5f97 busybox_unstripped
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to '')
-rw-r--r-- | networking/wget.c | 33 |
1 files changed, 14 insertions, 19 deletions
diff --git a/networking/wget.c b/networking/wget.c index 12ee29a6f..c9e576e69 100644 --- a/networking/wget.c +++ b/networking/wget.c | |||
@@ -762,12 +762,9 @@ static void spawn_ssl_client(const char *host, int network_fd, int flags) | |||
762 | static FILE* prepare_ftp_session(FILE **dfpp, struct host_info *target, len_and_sockaddr *lsa) | 762 | static FILE* prepare_ftp_session(FILE **dfpp, struct host_info *target, len_and_sockaddr *lsa) |
763 | { | 763 | { |
764 | FILE *sfp; | 764 | FILE *sfp; |
765 | char *str; | 765 | char *pass; |
766 | int port; | 766 | int port; |
767 | 767 | ||
768 | if (!target->user) | ||
769 | target->user = xstrdup("anonymous:busybox@"); | ||
770 | |||
771 | sfp = open_socket(lsa); | 768 | sfp = open_socket(lsa); |
772 | #if ENABLE_FEATURE_WGET_HTTPS | 769 | #if ENABLE_FEATURE_WGET_HTTPS |
773 | if (target->protocol == P_FTPS) | 770 | if (target->protocol == P_FTPS) |
@@ -778,18 +775,20 @@ static FILE* prepare_ftp_session(FILE **dfpp, struct host_info *target, len_and_ | |||
778 | bb_error_msg_and_die("%s", G.wget_buf); | 775 | bb_error_msg_and_die("%s", G.wget_buf); |
779 | /* note: ftpcmd() sanitizes G.wget_buf, ok to print */ | 776 | /* note: ftpcmd() sanitizes G.wget_buf, ok to print */ |
780 | 777 | ||
781 | /* | 778 | /* Split username:password pair */ |
782 | * Splitting username:password pair, | 779 | pass = (char*)"busybox"; /* password for "anonymous" */ |
783 | * trying to log in | 780 | if (target->user) { |
784 | */ | 781 | pass = strchr(target->user, ':'); |
785 | str = strchr(target->user, ':'); | 782 | if (pass) |
786 | if (str) | 783 | *pass++ = '\0'; |
787 | *str++ = '\0'; | 784 | } |
788 | switch (ftpcmd("USER ", target->user, sfp)) { | 785 | |
786 | /* Log in */ | ||
787 | switch (ftpcmd("USER ", target->user ?: "anonymous", sfp)) { | ||
789 | case 230: | 788 | case 230: |
790 | break; | 789 | break; |
791 | case 331: | 790 | case 331: |
792 | if (ftpcmd("PASS ", str, sfp) == 230) | 791 | if (ftpcmd("PASS ", pass, sfp) == 230) |
793 | break; | 792 | break; |
794 | /* fall through (failed login) */ | 793 | /* fall through (failed login) */ |
795 | default: | 794 | default: |
@@ -798,9 +797,7 @@ static FILE* prepare_ftp_session(FILE **dfpp, struct host_info *target, len_and_ | |||
798 | 797 | ||
799 | ftpcmd("TYPE I", NULL, sfp); | 798 | ftpcmd("TYPE I", NULL, sfp); |
800 | 799 | ||
801 | /* | 800 | /* Query file size */ |
802 | * Querying file size | ||
803 | */ | ||
804 | if (ftpcmd("SIZE ", target->path, sfp) == 213) { | 801 | if (ftpcmd("SIZE ", target->path, sfp) == 213) { |
805 | G.content_len = BB_STRTOOFF(G.wget_buf + 4, NULL, 10); | 802 | G.content_len = BB_STRTOOFF(G.wget_buf + 4, NULL, 10); |
806 | if (G.content_len < 0 || errno) { | 803 | if (G.content_len < 0 || errno) { |
@@ -809,9 +806,7 @@ static FILE* prepare_ftp_session(FILE **dfpp, struct host_info *target, len_and_ | |||
809 | G.got_clen = 1; | 806 | G.got_clen = 1; |
810 | } | 807 | } |
811 | 808 | ||
812 | /* | 809 | /* Enter passive mode */ |
813 | * Entering passive mode | ||
814 | */ | ||
815 | if (ENABLE_FEATURE_IPV6 && ftpcmd("EPSV", NULL, sfp) == 229) { | 810 | if (ENABLE_FEATURE_IPV6 && ftpcmd("EPSV", NULL, sfp) == 229) { |
816 | /* good */ | 811 | /* good */ |
817 | } else | 812 | } else |