]> granicus.if.org Git - php/commitdiff
MFH: Fixed bug #29678 (opendir() with ftp:// wrapper segfaults if path
authorIlia Alshanetsky <iliaa@php.net>
Mon, 16 Aug 2004 01:41:17 +0000 (01:41 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Mon, 16 Aug 2004 01:41:17 +0000 (01:41 +0000)
does not have trailing slash).

NEWS
ext/standard/ftp_fopen_wrapper.c

diff --git a/NEWS b/NEWS
index bf3f615ec2bac2175e3b969588cef33074c206b7..f62c5431b6f78d0ffa623958b302c2bec6759309 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,8 @@ PHP                                                                        NEWS
 ?? ??? 2004, PHP 5.0.2
 - Added PHP_EOL constant that contains the OS way of representing newlines.
   (Paul Hudson, Derick)
+- Fixed bug #29678 (opendir() with ftp:// wrapper segfaults if path does not
+  have trailing slash). (Ilia)
 - Fixed bug #29656 (segfault on result and statement properties) (Georg)
 
 12 Aug 2004, PHP 5.0.1
index 15e6c64385574db9f78237b4026734c89f31d5d4..bf398d6764050d32a2a9c4ccbcab15885af67b4d 100644 (file)
@@ -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';
 
@@ -647,6 +651,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");