summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIlia Alshanetsky <iliaa@php.net>2004-08-16 01:41:14 +0000
committerIlia Alshanetsky <iliaa@php.net>2004-08-16 01:41:14 +0000
commit60fc9c050a44e53bf33a819f60f50970bf1dca8c (patch)
tree81592cec394fbc4c8a9986c34da22c89875a430c
parentbe00addf85e82ad2a960d68bd522f91612133327 (diff)
downloadphp-git-60fc9c050a44e53bf33a819f60f50970bf1dca8c.tar.gz
Fixed bug #29678 (opendir() with ftp:// wrapper segfaults if path does not
have trailing slash).
-rw-r--r--ext/standard/ftp_fopen_wrapper.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/ext/standard/ftp_fopen_wrapper.c b/ext/standard/ftp_fopen_wrapper.c
index ce584cc018..2ab5e7d283 100644
--- a/ext/standard/ftp_fopen_wrapper.c
+++ b/ext/standard/ftp_fopen_wrapper.c
@@ -126,8 +126,12 @@ static php_stream *php_ftp_fopen_connect(php_stream_wrapper *wrapper, char *path
char tmp_line[512];
resource = php_url_parse(path);
- if (resource == NULL || resource->path == NULL)
+ if (resource == NULL || resource->path == NULL) {
+ if (resource && presource) {
+ *presource = resource;
+ }
return NULL;
+ }
use_ssl = resource->scheme && (strlen(resource->scheme) > 3) && resource->scheme[3] == 's';
@@ -659,6 +663,9 @@ php_stream * php_stream_ftp_opendir(php_stream_wrapper *wrapper, char *path, cha
unsigned short portno;
stream = php_ftp_fopen_connect(wrapper, path, mode, options, opened_path, context, &reuseid, &resource, &use_ssl, &use_ssl_on_data TSRMLS_CC);
+ if (!stream) {
+ goto opendir_errexit;
+ }
/* set the connection to be ascii */
php_stream_write_string(stream, "TYPE A\r\n");