Skip to content

Commit 8a313d8

Browse files
author
Jani Taskinen
committed
MFH:- This makes no sense with non-ipv6 builds. (and fixes lot of issues with misconfigured servers)
1 parent b9c22f2 commit 8a313d8

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

ext/standard/ftp_fopen_wrapper.c

+5-2
Original file line numberDiff line numberDiff line change
@@ -300,19 +300,21 @@ static php_stream *php_ftp_fopen_connect(php_stream_wrapper *wrapper, char *path
300300

301301
/* {{{ php_fopen_do_pasv
302302
*/
303-
static unsigned short php_fopen_do_pasv(php_stream *stream, char *ip, int ip_size, char **phoststart TSRMLS_DC)
303+
static unsigned short php_fopen_do_pasv(php_stream *stream, char *ip, size_t ip_size, char **phoststart TSRMLS_DC)
304304
{
305305
char tmp_line[512];
306306
int result, i;
307307
unsigned short portno;
308308
char *tpath, *ttpath, *hoststart=NULL;
309309

310+
#ifdef HAVE_IPV6
310311
/* We try EPSV first, needed for IPv6 and works on some IPv4 servers */
311312
php_stream_write_string(stream, "EPSV\r\n");
312313
result = GET_FTP_RESULT(stream);
313314

314315
/* check if we got a 229 response */
315316
if (result != 229) {
317+
#endif
316318
/* EPSV failed, let's try PASV */
317319
php_stream_write_string(stream, "PASV\r\n");
318320
result = GET_FTP_RESULT(stream);
@@ -357,6 +359,7 @@ static unsigned short php_fopen_do_pasv(php_stream *stream, char *ip, int ip_siz
357359
tpath++;
358360
/* pull out the LSB of the port */
359361
portno += (unsigned short) strtoul(tpath, &ttpath, 10);
362+
#ifdef HAVE_IPV6
360363
} else {
361364
/* parse epsv command (|||6446|) */
362365
for (i = 0, tpath = tmp_line + 4; *tpath; tpath++) {
@@ -372,7 +375,7 @@ static unsigned short php_fopen_do_pasv(php_stream *stream, char *ip, int ip_siz
372375
/* pull out the port */
373376
portno = (unsigned short) strtoul(tpath + 1, &ttpath, 10);
374377
}
375-
378+
#endif
376379
if (ttpath == NULL) {
377380
/* didn't get correct response from EPSV/PASV */
378381
return 0;

0 commit comments

Comments
 (0)