]> granicus.if.org Git - php/commitdiff
- Fixed bug #48590 (SoapClient does not honor max_redirects)
authorSriram Natarajan <srinatar@php.net>
Tue, 5 Jan 2010 03:07:43 +0000 (03:07 +0000)
committerSriram Natarajan <srinatar@php.net>
Tue, 5 Jan 2010 03:07:43 +0000 (03:07 +0000)
NEWS
ext/soap/php_http.c

diff --git a/NEWS b/NEWS
index 923f1feb6985b5dd457bc88020bac1dde7d3b3a7..3d404cb039168536bfa864443c2d50c7088e90d8 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -12,6 +12,7 @@ PHP                                                                        NEWS
   (Pierrick)
 - Fixed bug #50632 (filter_input() does not return default value if the
   variable does not exist). (Ilia)
+- Fixed bug #48590 (SoapClient does not honor max_redirects). (Sriram)
 - Fixed bug #48190 (Content-type parameter "boundary" is not case-insensitive
   in HTTP uploads). (Ilia)
 - Fixed bug #47409 (extract() problem with array containing word "this").
index a62c219c9922fa561fded0f2400606bc0649b12a..f14d2309a7964e7b4186ad16e5272d4501e09d96 100644 (file)
@@ -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;
                        }
                }