summaryrefslogtreecommitdiff
path: root/ext/ftp/ftp.c
diff options
context:
space:
mode:
Diffstat (limited to 'ext/ftp/ftp.c')
-rw-r--r--ext/ftp/ftp.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/ext/ftp/ftp.c b/ext/ftp/ftp.c
index bb41b1a621..b3548e70da 100644
--- a/ext/ftp/ftp.c
+++ b/ext/ftp/ftp.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2015 The PHP Group |
+ | Copyright (c) 1997-2016 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -754,10 +754,11 @@ ftp_pasv(ftpbuf_t *ftp, int pasv)
memset(&ftp->pasvaddr, 0, n);
sa = (struct sockaddr *) &ftp->pasvaddr;
-#if HAVE_IPV6
if (getpeername(ftp->fd, sa, &n) < 0) {
return 0;
}
+
+#if HAVE_IPV6
if (sa->sa_family == AF_INET6) {
struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *) sa;
char *endptr, delimiter;
@@ -810,8 +811,9 @@ ftp_pasv(ftpbuf_t *ftp, int pasv)
ipbox.c[n] = (unsigned char) b[n];
}
sin = (struct sockaddr_in *) sa;
- sin->sin_family = AF_INET;
- sin->sin_addr = ipbox.ia[0];
+ if (ftp->usepasvaddress) {
+ sin->sin_addr = ipbox.ia[0];
+ }
sin->sin_port = ipbox.s[2];
ftp->pasv = 2;