diff options
author | Ron Yorston <rmy@pobox.com> | 2018-02-13 09:44:44 +0000 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2018-02-13 09:44:44 +0000 |
commit | dc19a361bd6c6df30338371532691bbc7f7126bb (patch) | |
tree | 1fb2cd646d54b5f8e425c4f11f3e09fc21d1966b /networking/ftpgetput.c | |
parent | 096aee2bb468d1ab044de36e176ed1f6c7e3674d (diff) | |
parent | 3459024bf404af814cacfe90a0deb719e282ae62 (diff) | |
download | busybox-w32-dc19a361bd6c6df30338371532691bbc7f7126bb.tar.gz busybox-w32-dc19a361bd6c6df30338371532691bbc7f7126bb.tar.bz2 busybox-w32-dc19a361bd6c6df30338371532691bbc7f7126bb.zip |
Merge branch 'busybox' into merge
Diffstat (limited to 'networking/ftpgetput.c')
-rw-r--r-- | networking/ftpgetput.c | 44 |
1 files changed, 7 insertions, 37 deletions
diff --git a/networking/ftpgetput.c b/networking/ftpgetput.c index 029587aa2..ffc4cd5f1 100644 --- a/networking/ftpgetput.c +++ b/networking/ftpgetput.c | |||
@@ -158,46 +158,16 @@ static void ftp_login(void) | |||
158 | 158 | ||
159 | static int xconnect_ftpdata(void) | 159 | static int xconnect_ftpdata(void) |
160 | { | 160 | { |
161 | char *buf_ptr; | 161 | int port_num; |
162 | unsigned port_num; | ||
163 | 162 | ||
164 | /* | 163 | if (ENABLE_FEATURE_IPV6 && ftpcmd("EPSV", NULL) == 229) { |
165 | TODO: PASV command will not work for IPv6. RFC2428 describes | 164 | /* good */ |
166 | IPv6-capable "extended PASV" - EPSV. | 165 | } else if (ftpcmd("PASV", NULL) != 227) { |
167 | |||
168 | "EPSV [protocol]" asks server to bind to and listen on a data port | ||
169 | in specified protocol. Protocol is 1 for IPv4, 2 for IPv6. | ||
170 | If not specified, defaults to "same as used for control connection". | ||
171 | If server understood you, it should answer "229 <some text>(|||port|)" | ||
172 | where "|" are literal pipe chars and "port" is ASCII decimal port#. | ||
173 | |||
174 | There is also an IPv6-capable replacement for PORT (EPRT), | ||
175 | but we don't need that. | ||
176 | |||
177 | NB: PASV may still work for some servers even over IPv6. | ||
178 | For example, vsftp happily answers | ||
179 | "227 Entering Passive Mode (0,0,0,0,n,n)" and proceeds as usual. | ||
180 | |||
181 | TODO2: need to stop ignoring IP address in PASV response. | ||
182 | */ | ||
183 | |||
184 | if (ftpcmd("PASV", NULL) != 227) { | ||
185 | ftp_die("PASV"); | 166 | ftp_die("PASV"); |
186 | } | 167 | } |
187 | 168 | port_num = parse_pasv_epsv(buf); | |
188 | /* Response is "NNN garbageN1,N2,N3,N4,P1,P2[)garbage] | 169 | if (port_num < 0) |
189 | * Server's IP is N1.N2.N3.N4 (we ignore it) | 170 | ftp_die("PASV"); |
190 | * Server's port for data connection is P1*256+P2 */ | ||
191 | buf_ptr = strrchr(buf, ')'); | ||
192 | if (buf_ptr) *buf_ptr = '\0'; | ||
193 | |||
194 | buf_ptr = strrchr(buf, ','); | ||
195 | *buf_ptr = '\0'; | ||
196 | port_num = xatoul_range(buf_ptr + 1, 0, 255); | ||
197 | |||
198 | buf_ptr = strrchr(buf, ','); | ||
199 | *buf_ptr = '\0'; | ||
200 | port_num += xatoul_range(buf_ptr + 1, 0, 255) * 256; | ||
201 | 171 | ||
202 | set_nport(&lsa->u.sa, htons(port_num)); | 172 | set_nport(&lsa->u.sa, htons(port_num)); |
203 | return xconnect_stream(lsa); | 173 | return xconnect_stream(lsa); |