summaryrefslogtreecommitdiff
path: root/ext/soap/php_http.c
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
commit2c8bdf40d0e1a9373ac19253faac0e26887c7bcf (patch)
tree9989c8e6aa36abee1f1f89adbc884b20211f6c4c /ext/soap/php_http.c
parentc5c6bc8250bf3c20ac42ce32b324d00a1d2a5360 (diff)
downloadphp-git-2c8bdf40d0e1a9373ac19253faac0e26887c7bcf.tar.gz
- Fixed bug #48590 (SoapClient does not honor max_redirects)
Diffstat (limited to 'ext/soap/php_http.c')
-rw-r--r--ext/soap/php_http.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/ext/soap/php_http.c b/ext/soap/php_http.c
index a62c219c99..f14d2309a7 100644
--- a/ext/soap/php_http.c
+++ b/ext/soap/php_http.c
@@ -207,6 +207,7 @@ 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;
zend_bool old_allow_url_fopen;
@@ -283,6 +284,14 @@ int make_http_soap_request(zval *this_ptr,
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);}
@@ -1012,6 +1021,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;
}
}