mirror of
https://github.com/php/php-src.git
synced 2025-08-18 15:08:55 +02:00
MFH:- This makes no sense with non-ipv6 builds. (and fixes lot of issues with misconfigured servers)
This commit is contained in:
parent
b9c22f2b1e
commit
8a313d8e77
1 changed files with 5 additions and 2 deletions
|
@ -300,19 +300,21 @@ connect_errexit:
|
||||||
|
|
||||||
/* {{{ php_fopen_do_pasv
|
/* {{{ php_fopen_do_pasv
|
||||||
*/
|
*/
|
||||||
static unsigned short php_fopen_do_pasv(php_stream *stream, char *ip, int ip_size, char **phoststart TSRMLS_DC)
|
static unsigned short php_fopen_do_pasv(php_stream *stream, char *ip, size_t ip_size, char **phoststart TSRMLS_DC)
|
||||||
{
|
{
|
||||||
char tmp_line[512];
|
char tmp_line[512];
|
||||||
int result, i;
|
int result, i;
|
||||||
unsigned short portno;
|
unsigned short portno;
|
||||||
char *tpath, *ttpath, *hoststart=NULL;
|
char *tpath, *ttpath, *hoststart=NULL;
|
||||||
|
|
||||||
|
#ifdef HAVE_IPV6
|
||||||
/* We try EPSV first, needed for IPv6 and works on some IPv4 servers */
|
/* We try EPSV first, needed for IPv6 and works on some IPv4 servers */
|
||||||
php_stream_write_string(stream, "EPSV\r\n");
|
php_stream_write_string(stream, "EPSV\r\n");
|
||||||
result = GET_FTP_RESULT(stream);
|
result = GET_FTP_RESULT(stream);
|
||||||
|
|
||||||
/* check if we got a 229 response */
|
/* check if we got a 229 response */
|
||||||
if (result != 229) {
|
if (result != 229) {
|
||||||
|
#endif
|
||||||
/* EPSV failed, let's try PASV */
|
/* EPSV failed, let's try PASV */
|
||||||
php_stream_write_string(stream, "PASV\r\n");
|
php_stream_write_string(stream, "PASV\r\n");
|
||||||
result = GET_FTP_RESULT(stream);
|
result = GET_FTP_RESULT(stream);
|
||||||
|
@ -357,6 +359,7 @@ static unsigned short php_fopen_do_pasv(php_stream *stream, char *ip, int ip_siz
|
||||||
tpath++;
|
tpath++;
|
||||||
/* pull out the LSB of the port */
|
/* pull out the LSB of the port */
|
||||||
portno += (unsigned short) strtoul(tpath, &ttpath, 10);
|
portno += (unsigned short) strtoul(tpath, &ttpath, 10);
|
||||||
|
#ifdef HAVE_IPV6
|
||||||
} else {
|
} else {
|
||||||
/* parse epsv command (|||6446|) */
|
/* parse epsv command (|||6446|) */
|
||||||
for (i = 0, tpath = tmp_line + 4; *tpath; tpath++) {
|
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
|
||||||
/* pull out the port */
|
/* pull out the port */
|
||||||
portno = (unsigned short) strtoul(tpath + 1, &ttpath, 10);
|
portno = (unsigned short) strtoul(tpath + 1, &ttpath, 10);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
if (ttpath == NULL) {
|
if (ttpath == NULL) {
|
||||||
/* didn't get correct response from EPSV/PASV */
|
/* didn't get correct response from EPSV/PASV */
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue