diff options
Diffstat (limited to 'ext/standard/ftp_fopen_wrapper.c')
-rw-r--r-- | ext/standard/ftp_fopen_wrapper.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/ext/standard/ftp_fopen_wrapper.c b/ext/standard/ftp_fopen_wrapper.c index a28b6c14b1..f562827295 100644 --- a/ext/standard/ftp_fopen_wrapper.c +++ b/ext/standard/ftp_fopen_wrapper.c @@ -82,6 +82,7 @@ typedef struct _php_ftp_dirstream_data { */ static inline int get_ftp_result(php_stream *stream, char *buffer, size_t buffer_size) { + buffer[0] = '\0'; /* in case read fails to read anything */ while (php_stream_gets(stream, buffer, buffer_size-1) && !(isdigit((int) buffer[0]) && isdigit((int) buffer[1]) && isdigit((int) buffer[2]) && buffer[3] == ' ')); @@ -728,18 +729,6 @@ php_stream * php_stream_ftp_opendir(php_stream_wrapper *wrapper, const char *pat goto opendir_errexit; } - php_stream_context_set(datastream, context); - if (use_ssl_on_data && (php_stream_xport_crypto_setup(datastream, - STREAM_CRYPTO_METHOD_SSLv23_CLIENT, NULL) < 0 || - php_stream_xport_crypto_enable(datastream, 1) < 0)) { - - php_stream_wrapper_log_error(wrapper, options, "Unable to activate SSL mode"); - php_stream_close(datastream); - datastream = NULL; - goto opendir_errexit; - } - - php_stream_printf(stream, "NLST %s\r\n", (resource->path != NULL ? resource->path : "/")); result = GET_FTP_RESULT(stream); @@ -752,6 +741,17 @@ php_stream * php_stream_ftp_opendir(php_stream_wrapper *wrapper, const char *pat goto opendir_errexit; } + php_stream_context_set(datastream, context); + if (use_ssl_on_data && (php_stream_xport_crypto_setup(datastream, + STREAM_CRYPTO_METHOD_SSLv23_CLIENT, NULL) < 0 || + php_stream_xport_crypto_enable(datastream, 1) < 0)) { + + php_stream_wrapper_log_error(wrapper, options, "Unable to activate SSL mode"); + php_stream_close(datastream); + datastream = NULL; + goto opendir_errexit; + } + php_url_free(resource); dirsdata = emalloc(sizeof *dirsdata); |