summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSriram Natarajan <srinatar@php.net>2010-01-05 03:07:43 +0000
committerSriram Natarajan <srinatar@php.net>2010-01-05 03:07:43 +0000
commitb5d9f84d9421a5ef22732284738d9f89d53bf1ad (patch)
treeb26445fc3518d7ac9652ef66dbf3ceba6ffff7a4
parentf8b7f083ce36cab98fd5d1b5f94b03ecc729c028 (diff)
downloadphp-git-b5d9f84d9421a5ef22732284738d9f89d53bf1ad.tar.gz
- Fixed bug #48590 (SoapClient does not honor max_redirects)
-rw-r--r--ext/soap/php_http.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/ext/soap/php_http.c b/ext/soap/php_http.c
index d302d07f0a..68643c9ae8 100644
--- a/ext/soap/php_http.c
+++ b/ext/soap/php_http.c
@@ -207,11 +207,13 @@ int make_http_soap_request(zval *this_ptr,
int http_1_1;
int http_status;
int content_type_xml = 0;
+ long redirect_max = 20;
char *content_encoding;
char *http_msg = NULL;
char *old_allow_url_fopen_list;
soap_client_object *client;
zval **tmp;
+ php_stream_context *context = NULL;
if (this_ptr == NULL || Z_TYPE_P(this_ptr) != IS_OBJECT) {
return FALSE;
@@ -278,6 +280,19 @@ int make_http_soap_request(zval *this_ptr,
phpurl = php_url_parse(location);
}
+ if (SUCCESS == zend_hash_find(Z_OBJPROP_P(this_ptr),
+ "_stream_context", sizeof("_stream_context"), (void**)&tmp)) {
+ context = php_stream_context_from_zval(*tmp, 0);
+ }
+
+ if (context &&
+ php_stream_context_get_option(context, "http", "max_redirects", &tmp) == SUCCESS) {
+ if (Z_TYPE_PP(tmp) != IS_STRING || !is_numeric_string(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), &redirect_max, NULL, 1)) {
+ if (Z_TYPE_PP(tmp) == IS_LONG)
+ redirect_max = Z_LVAL_PP(tmp);
+ }
+ }
+
try_again:
if (phpurl == NULL || phpurl->host == NULL) {
if (phpurl != NULL) {php_url_free(phpurl);}
@@ -1018,6 +1033,12 @@ try_again:
}
phpurl = new_url;
+ if (--redirect_max < 1) {
+ smart_str_free(&soap_headers_z);
+ add_soap_fault(this_ptr, "HTTP", "Redirection limit reached, aborting", NULL, NULL TSRMLS_CC);
+ return FALSE;
+ }
+
goto try_again;
}
}