sesser          Sun Sep  8 15:35:43 2002 EDT

  Modified files:              
    /php4/ext/standard  ftp_fopen_wrapper.c 
  Log:
  ftp(s) fopen() wrapper does no longer ignore the ip returned by PASV.
  
  
  
Index: php4/ext/standard/ftp_fopen_wrapper.c
diff -u php4/ext/standard/ftp_fopen_wrapper.c:1.29 
php4/ext/standard/ftp_fopen_wrapper.c:1.30
--- php4/ext/standard/ftp_fopen_wrapper.c:1.29  Sun Sep  8 15:11:07 2002
+++ php4/ext/standard/ftp_fopen_wrapper.c       Sun Sep  8 15:35:42 2002
@@ -17,7 +17,7 @@
    |          Hartmut Holzgraefe <[EMAIL PROTECTED]>                       |
    +----------------------------------------------------------------------+
  */
-/* $Id: ftp_fopen_wrapper.c,v 1.29 2002/09/08 19:11:07 sesser Exp $ */
+/* $Id: ftp_fopen_wrapper.c,v 1.30 2002/09/08 19:35:42 sesser Exp $ */
 
 #include "php.h"
 #include "php_globals.h"
@@ -137,11 +137,12 @@
        php_stream *stream=NULL, *datastream=NULL;
        php_url *resource=NULL;
        char tmp_line[512];
+       char ip[sizeof("123.123.123.123")];
        unsigned short portno;
        char *scratch;
        int result;
        int i, use_ssl, use_ssl_on_data=0;
-       char *tpath, *ttpath;
+       char *tpath, *ttpath, *hoststart=NULL;
        size_t file_size = 0;
 
        if (strchr(mode, 'a') || strchr(mode, '+')) {
@@ -331,13 +332,20 @@
                for (tpath += 4; *tpath && !isdigit((int) *tpath); tpath++);
                if (!*tpath)
                        goto errexit;
-               /* skip over the host ip, we just assume it's the same */
+               /* skip over the host ip, to get the port */
+               hoststart = tpath;
                for (i = 0; i < 4; i++) {
                        for (; isdigit((int) *tpath); tpath++);
                        if (*tpath != ',')
                                goto errexit;
+                       *tpath='.';     
                        tpath++;
                }
+               tpath[-1] = '\0';
+               memcpy(ip, hoststart, sizeof(ip));
+               ip[sizeof(ip)-1] = '\0';
+               hoststart = ip;
+               
                /* pull out the MSB of the port */
                portno = (unsigned short) strtol(tpath, &ttpath, 10) * 256;
                if (ttpath == NULL) {
@@ -392,7 +400,10 @@
        }
 
        /* open the data channel */
-       datastream = php_stream_sock_open_host(resource->host, portno, SOCK_STREAM, 0, 
0);
+       if (hoststart == NULL) {
+               hoststart = resource->host;
+       }
+       datastream = php_stream_sock_open_host(hoststart, portno, SOCK_STREAM, 0, 0);
        if (datastream == NULL)
                goto errexit;
                



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to