summaryrefslogtreecommitdiff
path: root/ext/standard
diff options
context:
space:
mode:
authorWez Furlong <wez@php.net>2002-08-11 10:53:10 +0000
committerWez Furlong <wez@php.net>2002-08-11 10:53:10 +0000
commit5a21ab42cb0a7b4d0bc5661a6ae7d6ac085ed800 (patch)
tree8823280330d44c1cf243ea9709996341b6143439 /ext/standard
parent1861f1bae38472d7927d114a99d74ab40cd0eeee (diff)
downloadphp-git-5a21ab42cb0a7b4d0bc5661a6ae7d6ac085ed800.tar.gz
Introduce an error stack for wrappers, to help prevent multiple errors
and warnings (some of which are bogus) when there are problems opening streams. Implement sanity check on the mode used to open ftp and http connections. This fixes Bug 12004.
Diffstat (limited to 'ext/standard')
-rw-r--r--ext/standard/ftp_fopen_wrapper.c7
-rw-r--r--ext/standard/http_fopen_wrapper.c14
2 files changed, 14 insertions, 7 deletions
diff --git a/ext/standard/ftp_fopen_wrapper.c b/ext/standard/ftp_fopen_wrapper.c
index 9bbdbedee4..b5d3ccdc16 100644
--- a/ext/standard/ftp_fopen_wrapper.c
+++ b/ext/standard/ftp_fopen_wrapper.c
@@ -115,6 +115,11 @@ php_stream * php_stream_url_wrap_ftp(php_stream_wrapper *wrapper, char *path, ch
int i;
char *tpath, *ttpath;
size_t file_size = 0;
+
+ if (strchr(mode, 'a') || strchr(mode, '+')) {
+ php_stream_wrapper_log_error(wrapper, options, "FTP does not support simultaneous read/write connections.");
+ return NULL;
+ }
resource = php_url_parse((char *) path);
if (resource == NULL || resource->path == NULL)
@@ -314,7 +319,7 @@ php_stream * php_stream_url_wrap_ftp(php_stream_wrapper *wrapper, char *path, ch
php_stream_close(stream);
}
if (tmp_line[0] != '\0')
- zend_error(E_WARNING, "FTP server reports %s", tmp_line);
+ php_stream_wrapper_log_error(wrapper, options, "FTP server reports %s", tmp_line);
return NULL;
}
/* }}} */
diff --git a/ext/standard/http_fopen_wrapper.c b/ext/standard/http_fopen_wrapper.c
index 3a2aa8e57e..c06dc6210c 100644
--- a/ext/standard/http_fopen_wrapper.c
+++ b/ext/standard/http_fopen_wrapper.c
@@ -86,11 +86,16 @@ php_stream *php_stream_url_wrap_http(php_stream_wrapper *wrapper, char *path, ch
char tmp_line[128];
size_t chunk_size = 0, file_size = 0;
+ if (strchr(mode, 'a') || strchr(mode, '+') || strchr(mode, 'w')) {
+ php_stream_wrapper_log_error(wrapper, options, "HTTP wrapper does not writeable connections.");
+ return NULL;
+ }
+
resource = php_url_parse(path);
if (resource == NULL)
return NULL;
- use_ssl = resource->scheme && resource->scheme[4] == 's';
+ use_ssl = resource->scheme && (strlen(resource->scheme) > 4) && resource->scheme[4] == 's';
/* choose default ports */
if (use_ssl && resource->port == 0)
@@ -113,9 +118,7 @@ php_stream *php_stream_url_wrap_http(php_stream_wrapper *wrapper, char *path, ch
#if HAVE_OPENSSL_EXT
if (use_ssl) {
if (php_stream_sock_ssl_activate(stream, 1) == FAILURE) {
- if (options & REPORT_ERRORS) {
- zend_error(E_WARNING, "Unable to activate SSL mode");
- }
+ php_stream_wrapper_log_error(wrapper, options, "Unable to activate SSL mode");
php_stream_close(stream);
stream = NULL;
goto out;
@@ -323,8 +326,7 @@ php_stream *php_stream_url_wrap_http(php_stream_wrapper *wrapper, char *path, ch
FREE_ZVAL(stream->wrapperdata);
}
} else {
- if (options & REPORT_ERRORS)
- zend_error(E_WARNING, "HTTP request failed! %s", tmp_line);
+ php_stream_wrapper_log_error(wrapper, options, "HTTP request failed! %s", tmp_line);
}
}
out: