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-1783ffa990814e2aac14e7ff5a4bbf2d5bebe3cc.tar.gz
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_
/*
* Entering passive mode
*/
+ if (ENABLE_FEATURE_IPV6 && ftpcmd("EPSV", NULL, sfp) == 229) {
+ /* good */
+ } else
if (ftpcmd("PASV", NULL, sfp) != 227) {
pasv_error:
bb_error_msg_and_die("bad response to %s: %s", "PASV", sanitize_string(G.wget_buf));
}
- // Response is "227 garbageN1,N2,N3,N4,P1,P2[)garbage]
- // Server's IP is N1.N2.N3.N4 (we ignore it)
- // Server's port for data connection is P1*256+P2
- str = strrchr(G.wget_buf, ')');
- if (str) str[0] = '\0';
- str = strrchr(G.wget_buf, ',');
- if (!str) goto pasv_error;
- port = xatou_range(str+1, 0, 255);
- *str = '\0';
- str = strrchr(G.wget_buf, ',');
- if (!str) goto pasv_error;
- port += xatou_range(str+1, 0, 255) * 256;
+ port = parse_pasv_epsv(G.wget_buf);
+ if (port < 0)
+ goto pasv_error;
+
set_nport(&lsa->u.sa, htons(port));
*dfpp = open_socket(lsa);