Skip to content

Commit 3587185

Browse files
committed
MFH: fix invalid read when opendir over FTP fails (coverity issue #462)
1 parent 7985002 commit 3587185

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

ext/standard/ftp_fopen_wrapper.c

+4-1
Original file line numberDiff line numberDiff line change
@@ -669,6 +669,8 @@ php_stream * php_stream_ftp_opendir(php_stream_wrapper *wrapper, char *path, cha
669669
char ip[sizeof("123.123.123.123")];
670670
unsigned short portno;
671671

672+
tmp_line[0] = '\0';
673+
672674
stream = php_ftp_fopen_connect(wrapper, path, mode, options, opened_path, context, &reuseid, &resource, &use_ssl, &use_ssl_on_data TSRMLS_CC);
673675
if (!stream) {
674676
goto opendir_errexit;
@@ -734,8 +736,9 @@ php_stream * php_stream_ftp_opendir(php_stream_wrapper *wrapper, char *path, cha
734736
php_stream_notify_error(context, PHP_STREAM_NOTIFY_FAILURE, tmp_line, result);
735737
php_stream_close(stream);
736738
}
737-
if (tmp_line[0] != '\0')
739+
if (tmp_line[0] != '\0') {
738740
php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "FTP server reports %s", tmp_line);
741+
}
739742
return NULL;
740743
}
741744
/* }}} */

0 commit comments

Comments
 (0)