aboutsummaryrefslogtreecommitdiff
path: root/networking/wget.c
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2018-02-06 15:48:12 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2018-02-06 15:48:12 +0100
commit1783ffa990814e2aac14e7ff5a4bbf2d5bebe3cc (patch)
tree7e792db0260222476ec186db33fec49a22039731 /networking/wget.c
parent403f2999f94937ba3f37db6d093832f636815bb9 (diff)
downloadbusybox-w32-1783ffa990814e2aac14e7ff5a4bbf2d5bebe3cc.tar.gz
busybox-w32-1783ffa990814e2aac14e7ff5a4bbf2d5bebe3cc.tar.bz2
busybox-w32-1783ffa990814e2aac14e7ff5a4bbf2d5bebe3cc.zip
wget: add EPSV support
function old new delta parse_pasv_epsv - 151 +151 wget_main 2440 2382 -58 xconnect_ftpdata 223 94 -129 ------------------------------------------------------------------------------ (add/remove: 2/0 grow/shrink: 0/2 up/down: 151/-187) Total: -36 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'networking/wget.c')
-rw-r--r--networking/wget.c19
1 files changed, 7 insertions, 12 deletions
diff --git a/networking/wget.c b/networking/wget.c
index daa728a9d..7ca4bfb33 100644
--- a/networking/wget.c
+++ b/networking/wget.c
@@ -791,22 +791,17 @@ static FILE* prepare_ftp_session(FILE **dfpp, struct host_info *target, len_and_
791 /* 791 /*
792 * Entering passive mode 792 * Entering passive mode
793 */ 793 */
794 if (ENABLE_FEATURE_IPV6 && ftpcmd("EPSV", NULL, sfp) == 229) {
795 /* good */
796 } else
794 if (ftpcmd("PASV", NULL, sfp) != 227) { 797 if (ftpcmd("PASV", NULL, sfp) != 227) {
795 pasv_error: 798 pasv_error:
796 bb_error_msg_and_die("bad response to %s: %s", "PASV", sanitize_string(G.wget_buf)); 799 bb_error_msg_and_die("bad response to %s: %s", "PASV", sanitize_string(G.wget_buf));
797 } 800 }
798 // Response is "227 garbageN1,N2,N3,N4,P1,P2[)garbage] 801 port = parse_pasv_epsv(G.wget_buf);
799 // Server's IP is N1.N2.N3.N4 (we ignore it) 802 if (port < 0)
800 // Server's port for data connection is P1*256+P2 803 goto pasv_error;
801 str = strrchr(G.wget_buf, ')'); 804
802 if (str) str[0] = '\0';
803 str = strrchr(G.wget_buf, ',');
804 if (!str) goto pasv_error;
805 port = xatou_range(str+1, 0, 255);
806 *str = '\0';
807 str = strrchr(G.wget_buf, ',');
808 if (!str) goto pasv_error;
809 port += xatou_range(str+1, 0, 255) * 256;
810 set_nport(&lsa->u.sa, htons(port)); 805 set_nport(&lsa->u.sa, htons(port));
811 806
812 *dfpp = open_socket(lsa); 807 *dfpp = open_socket(lsa);