summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIlia Alshanetsky <iliaa@php.net>2002-11-25 22:00:52 +0000
committerIlia Alshanetsky <iliaa@php.net>2002-11-25 22:00:52 +0000
commit693fd4a36b2bd2536506507d7dc3ad949f76144b (patch)
tree4a58ac95e188118330b5dc4091a56c5d3b021164
parentd9cf3c2a0ead71dd9d803f122da723089c0440de (diff)
downloadphp-git-693fd4a36b2bd2536506507d7dc3ad949f76144b.tar.gz
Added a check to determine if the file can be retrieved or sent.
This check also prevents incorrect error reporting in the event the retrieval or the sending of the file cannot be accomplished.
-rw-r--r--ext/standard/ftp_fopen_wrapper.c27
1 files changed, 19 insertions, 8 deletions
diff --git a/ext/standard/ftp_fopen_wrapper.c b/ext/standard/ftp_fopen_wrapper.c
index 3145e83f0a..a824812f58 100644
--- a/ext/standard/ftp_fopen_wrapper.c
+++ b/ext/standard/ftp_fopen_wrapper.c
@@ -402,21 +402,32 @@ php_stream * php_stream_url_wrap_ftp(php_stream_wrapper *wrapper, char *path, ch
php_stream_write_string(stream, "/");
}
php_stream_write_string(stream, "\r\n");
+
+ /* open the data channel */
+ if (hoststart == NULL) {
+ hoststart = resource->host;
+ }
+ datastream = php_stream_sock_open_host(hoststart, portno, SOCK_STREAM, 0, 0);
+ if (datastream == NULL) {
+ goto errexit;
+ }
+ result = GET_FTP_RESULT(stream);
+ if (result != 150) {
+ /* Could not retrieve or send the file
+ * this data will only be sent to us after connection on the data port was initiated.
+ */
+ php_stream_close(datastream);
+ datastream = NULL;
+ goto errexit;
+ }
+
/* close control connection if not in ssl mode */
if (!use_ssl) {
php_stream_write_string(stream, "QUIT\r\n");
php_stream_close(stream);
stream = NULL;
}
-
- /* open the data channel */
- if (hoststart == NULL) {
- hoststart = resource->host;
- }
- datastream = php_stream_sock_open_host(hoststart, portno, SOCK_STREAM, 0, 0);
- if (datastream == NULL)
- goto errexit;
php_stream_context_set(datastream, context);
php_stream_notify_progress_init(context, 0, file_size);