From 3587185a89b552142e22c773e4826d4fa3de2e7c Mon Sep 17 00:00:00 2001 From: Antony Dovgal Date: Fri, 21 Sep 2007 12:57:38 +0000 Subject: [PATCH] MFH: fix invalid read when opendir over FTP fails (coverity issue #462) --- ext/standard/ftp_fopen_wrapper.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ext/standard/ftp_fopen_wrapper.c b/ext/standard/ftp_fopen_wrapper.c index 7ee5618575..f6ed4d68f2 100644 --- a/ext/standard/ftp_fopen_wrapper.c +++ b/ext/standard/ftp_fopen_wrapper.c @@ -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; } /* }}} */ -- 2.50.1