]> granicus.if.org Git - php/commitdiff
MFH: fix invalid read when opendir over FTP fails (coverity issue #462)
authorAntony Dovgal <tony2001@php.net>
Fri, 21 Sep 2007 12:57:38 +0000 (12:57 +0000)
committerAntony Dovgal <tony2001@php.net>
Fri, 21 Sep 2007 12:57:38 +0000 (12:57 +0000)
ext/standard/ftp_fopen_wrapper.c

index 7ee5618575b97168bae649465b8ef570d3e74d55..f6ed4d68f2f1129c296a65c794a65d22e4aaea8d 100644 (file)
@@ -669,6 +669,8 @@ php_stream * php_stream_ftp_opendir(php_stream_wrapper *wrapper, char *path, cha
        char ip[sizeof("123.123.123.123")];
        unsigned short portno;
 
+       tmp_line[0] = '\0';
+
        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;   
@@ -734,8 +736,9 @@ php_stream * php_stream_ftp_opendir(php_stream_wrapper *wrapper, char *path, cha
                php_stream_notify_error(context, PHP_STREAM_NOTIFY_FAILURE, tmp_line, result);
                php_stream_close(stream);
        }
-       if (tmp_line[0] != '\0')
+       if (tmp_line[0] != '\0') {
                php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "FTP server reports %s", tmp_line);
+       }
        return NULL;
 }
 /* }}} */