]> granicus.if.org Git - php/commitdiff
Implement FR #55651 (Option to ignore the returned FTP PASV address)
authorAvi Brender <abrender@elitehosts.com>
Tue, 15 Dec 2015 09:51:32 +0000 (11:51 +0200)
committerLior Kaplan <kaplanlior@gmail.com>
Tue, 15 Dec 2015 09:51:32 +0000 (11:51 +0200)
1  2 
ext/ftp/ftp.c
ext/ftp/ftp.h
ext/ftp/php_ftp.c
ext/ftp/php_ftp.h

diff --cc ext/ftp/ftp.c
Simple merge
diff --cc ext/ftp/ftp.h
index 546c69ccb7a77eb513686d3b48b20a9a264e4751,201ec5d5711a72c2a68d38d0aab4e64ff81bbbe0..aed416588fc51defeabbe5605c46327161575372
@@@ -69,8 -70,9 +70,9 @@@ typedef struct ftpbu
        ftptype_t       type;                   /* current transfer type */
        int             pasv;                   /* 0=off; 1=pasv; 2=ready */
        php_sockaddr_storage    pasvaddr;       /* passive mode address */
 -      long    timeout_sec;    /* User configurable timeout (seconds) */
 +      zend_long       timeout_sec;    /* User configurable timeout (seconds) */
        int                     autoseek;       /* User configurable autoseek flag */
+       int                     usepasvaddress; /* Use the address returned by the pasv command */
  
        int                             nb;             /* "nonblocking" transfer in progress */
        databuf_t               *data;  /* Data connection for "nonblocking" transfers */
index eaed5c6847ad5c80a221e142b32ea10aceeaeeb3,dc474dfefd5cd1ea439a0851fa9614cbde46aec8..ca6272079011642b50a2e9956782553661fa89cd
@@@ -379,7 -364,8 +380,8 @@@ PHP_FUNCTION(ftp_connect
  
        /* autoseek for resuming */
        ftp->autoseek = FTP_DEFAULT_AUTOSEEK;
 -#if HAVE_OPENSSL_EXT
+       ftp->usepasvaddress = FTP_DEFAULT_USEPASVADDRESS;
 +#ifdef HAVE_FTP_SSL
        /* disable ssl */
        ftp->use_ssl = 0;
  #endif
@@@ -1475,11 -1399,20 +1478,20 @@@ PHP_FUNCTION(ftp_set_option
                                        zend_zval_type_name(z_value));
                                RETURN_FALSE;
                        }
 -                      ftp->autoseek = Z_LVAL_P(z_value);
 +                      ftp->autoseek = Z_TYPE_P(z_value) == IS_TRUE ? 1 : 0;
                        RETURN_TRUE;
                        break;
 -                      if (Z_TYPE_P(z_value) != IS_BOOL) {
 -                              php_error_docref(NULL TSRMLS_CC, E_WARNING, "Option USEPASVADDRESS expects value of type boolean, %s given",
+               case PHP_FTP_OPT_USEPASVADDRESS:
 -                      ftp->usepasvaddress = Z_LVAL_P(z_value);
++                      if (Z_TYPE_P(z_value) != IS_TRUE && Z_TYPE_P(z_value) != IS_FALSE) {
++                              php_error_docref(NULL, E_WARNING, "Option USEPASVADDRESS expects value of type boolean, %s given",
+                                       zend_zval_type_name(z_value));
+                               RETURN_FALSE;
+                       }
++                      ftp->usepasvaddress = Z_TYPE_P(z_value) == IS_TRUE ? 1 : 0;
+                       RETURN_TRUE;
+                       break;
                default:
 -                      php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown option '%ld'", option);
 +                      php_error_docref(NULL, E_WARNING, "Unknown option '%pd'", option);
                        RETURN_FALSE;
                        break;
        }
@@@ -1509,8 -1440,11 +1521,11 @@@ PHP_FUNCTION(ftp_get_option
                case PHP_FTP_OPT_AUTOSEEK:
                        RETURN_BOOL(ftp->autoseek);
                        break;
+               case PHP_FTP_OPT_USEPASVADDRESS:
+                       RETURN_BOOL(ftp->usepasvaddress);
+                       break;
                default:
 -                      php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown option '%ld'", option);
 +                      php_error_docref(NULL, E_WARNING, "Unknown option '%pd'", option);
                        RETURN_FALSE;
                        break;
        }
index 3ddc76f074d894879e2b719b0be062fb106f38a1,6b52fa658cd48066e670e5f5fcb75b85dd0f0081..8000a3e3c94e767ba9ea624527658d3b325c9896
  extern zend_module_entry php_ftp_module_entry;
  #define php_ftp_module_ptr &php_ftp_module_entry
  
 +#include "php_version.h"
 +#define PHP_FTP_VERSION PHP_VERSION
 +
  #define PHP_FTP_OPT_TIMEOUT_SEC       0
  #define PHP_FTP_OPT_AUTOSEEK  1
+ #define PHP_FTP_OPT_USEPASVADDRESS    2
  #define PHP_FTP_AUTORESUME            -1
  
  PHP_MINIT_FUNCTION(ftp);